From 9f08b0a6a5e0f60be3d589a9cff2222149deadeb Mon Sep 17 00:00:00 2001 From: Urvish Date: Thu, 5 Nov 2026 15:29:53 +0530 Subject: [PATCH] fix(auth): clear mobile number field automatically when country changes during registration --- src/components/auth/AuthModal.tsx | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/components/auth/AuthModal.tsx b/src/components/auth/AuthModal.tsx index ec92ce0..1d71255 100644 --- a/src/components/auth/AuthModal.tsx +++ b/src/components/auth/AuthModal.tsx @@ -294,11 +294,13 @@ export const AuthModal: React.FC = ({ value={authDialCode} onChange={(e) => { const newCode = e.target.value; - setAuthDialCode(newCode); - const rule = getCountryRuleByDialCode(newCode); - if (rule && rule.country !== 'Other') { - setAuthCountry(rule.country); - setAuthPhone(cleanPhoneInput(authPhone, rule.maxLength, false)); + if (newCode !== authDialCode) { + setAuthDialCode(newCode); + const rule = getCountryRuleByDialCode(newCode); + if (rule && rule.country !== 'Other') { + setAuthCountry(rule.country); + } + setAuthPhone(''); } }} className="w-full bg-slate-950 border border-slate-800 rounded-xl px-2.5 py-2.5 text-xs sm:text-sm font-semibold text-white focus:outline-none focus:border-indigo-500 appearance-none pr-6" @@ -341,11 +343,13 @@ export const AuthModal: React.FC = ({ value={authCountry} onChange={(e) => { const newCountry = e.target.value; - setAuthCountry(newCountry); - const rule = getCountryRuleByName(newCountry); - if (rule) { - setAuthDialCode(rule.code); - setAuthPhone(cleanPhoneInput(authPhone, rule.maxLength, false)); + if (newCountry !== authCountry) { + setAuthCountry(newCountry); + const rule = getCountryRuleByName(newCountry); + if (rule) { + setAuthDialCode(rule.code); + } + setAuthPhone(''); } }} className="w-full bg-slate-950 border border-slate-800 rounded-xl px-4 py-2.5 text-sm font-semibold text-white focus:outline-none focus:border-indigo-500 appearance-none" -- 2.34.1