Skip to content

Commit a700c42

Browse files
committed
Merge branch 'frontend-country-selector'
2 parents ab577bb + 8f0d103 commit a700c42

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

frontends/web/src/routes/market/components/countryselect.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { SingleValue } from 'react-select';
1919
import { useDarkmode } from '@/hooks/darkmode';
2020
import { Dropdown } from '@/components/dropdown/dropdown';
2121
import { GlobeDark, GlobeLight } from '@/components/icon';
22-
import { i18n } from '@/i18n/i18n';
2322
import styles from './countryselect.module.css';
2423

2524
export type TOption = {
@@ -59,13 +58,12 @@ const Option = ({ props }: {props: TOption}) => {
5958

6059
const CountrySelect = ({ onChangeRegion, regions, selectedRegion }: TProps) => {
6160
const { t } = useTranslation();
62-
let selectedRegionName = t('buy.exchange.selectRegion');
63-
if (selectedRegion) {
64-
selectedRegionName = new Intl.DisplayNames([i18n.language], { type: 'region' }).of(selectedRegion) || '';
65-
}
61+
62+
// find and pass the default object, react-select requires object identity matching, not just value equality
63+
const defaultValue = regions.find(region => region.value === selectedRegion);
6664
return (
6765
<Dropdown
68-
defaultValue={{ label: selectedRegionName, value: selectedRegion }}
66+
value={defaultValue}
6967
className={styles.select}
7068
renderOptions={(o) => <Option props={o} />}
7169
isSearchable={true}

0 commit comments

Comments
 (0)