fix: case insensitive country name and country abbreviation search in region selection (#1394)

This commit is contained in:
Chell
2022-12-11 11:14:25 +01:00
committed by GitHub
parent eca2527bc0
commit b968bf033c

View File

@ -42,12 +42,15 @@ class SelectRegionBox extends React.Component {
placeholder="Please select country/region" placeholder="Please select country/region"
onChange={(value => {this.onChange(value);})} onChange={(value => {this.onChange(value);})}
filterOption={(input, option) => filterOption={(input, option) =>
option.label.indexOf(input) >= 0 (option?.label ?? "").toLowerCase().includes(input.toLowerCase())
}
filterSort={(optionA, optionB) =>
(optionA?.label ?? "").toLowerCase().localeCompare((optionB?.label ?? "").toLowerCase())
} }
> >
{ {
Setting.CountryRegionData.map((item, index) => ( Setting.CountryRegionData.map((item, index) => (
<Option key={index} value={item.code} label={item.code} > <Option key={index} value={item.code} label={`${item.name} (${item.code})`} >
<img src={`${Setting.StaticBaseUrl}/flag-icons/${item.code}.svg`} alt={item.name} height={20} style={{marginRight: 10}} /> <img src={`${Setting.StaticBaseUrl}/flag-icons/${item.code}.svg`} alt={item.name} height={20} style={{marginRight: 10}} />
{`${item.name} (${item.code})`} {`${item.name} (${item.code})`}
</Option> </Option>