diff --git a/src/features/profile/components/CountryCodeSelector.tsx b/src/features/profile/components/CountryCodeSelector.tsx index 5561f6f..c965239 100644 --- a/src/features/profile/components/CountryCodeSelector.tsx +++ b/src/features/profile/components/CountryCodeSelector.tsx @@ -76,10 +76,10 @@ export function CountryCodeSelector({ [searchTerm, t], ); - const initialIndex = Math.max( - 0, - filteredCountries.findIndex((c) => c.phone === value), - ); + const initialIndex = useMemo(() => { + const index = filteredCountries.findIndex((c) => c.phone === value); + return Math.max(0, index); + }, [filteredCountries, value]); return ( - {/* Virtualized country list */} - + {filteredCountries.length === 0 ? ( @@ -177,12 +176,18 @@ export function CountryCodeSelector({ ( handleSelect(country)} + sx={{ + minHeight: '48px', + '&.Mui-selected': { + backgroundColor: 'action.selected', + }, + }} > )} - computeItemKey={(_, c) => c.code} + computeItemKey={(_, country) => country.code} /> )} diff --git a/src/features/profile/types/settingsType.ts b/src/features/profile/types/settingsType.ts index 1cccfc1..eefcdd7 100644 --- a/src/features/profile/types/settingsType.ts +++ b/src/features/profile/types/settingsType.ts @@ -1,4 +1,5 @@ import type { TFunction } from 'i18next'; +import type { CountryCode } from '@/types/commonTypes'; export enum Gender { Male = 2, @@ -107,8 +108,8 @@ export interface PhoneDisplayProps { export interface PhoneEditFormProps { phoneNumber: string; setPhoneNumber: (v: string) => void; - countryCode: string; - setCountryCode: (v: string) => void; + countryCode: CountryCode; + setCountryCode: (v: CountryCode) => void; verificationCode: string; setVerificationCode: (v: string) => void; isVerified: boolean;