Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,11 @@ export const CountryPicker = ({
}, [showOnly, excludedCountries, lang]);

const resultCountries = React.useMemo(() => {
const lowerSearchValue = searchValue.toLowerCase();
const lowerSearchValue = searchValue.toLowerCase().trim();
const searchDialCode = searchValue.trim();

return codes.filter((country) => {
if (country?.dial_code.includes(searchValue) ||
if (country?.dial_code.includes(searchDialCode) ||
country?.name[lang || 'en'].toLowerCase().includes(lowerSearchValue) ||
removeDiacritics(country?.name[lang || 'en'].toLowerCase()).includes(lowerSearchValue)
) {
Expand Down Expand Up @@ -385,12 +386,13 @@ export const CountryList = ({
}, [showOnly, excludedCountries]);

const resultCountries = React.useMemo(() => {
const lowerSearchValue = searchValue.toLowerCase();
const lowerSearchValue = searchValue.toLowerCase().trim();
const searchDialCode = searchValue.trim();

return codes.filter((country) => {
if (country?.dial_code.includes(searchValue) ||
country?.name[lang || 'en'].toLowerCase().includes(lowerSearchValue.trim()) ||
removeDiacritics(country?.name[lang || 'en'].toLowerCase()).includes(lowerSearchValue.trim())
if (country?.dial_code.includes(searchDialCode) ||
country?.name[lang || 'en'].toLowerCase().includes(lowerSearchValue) ||
removeDiacritics(country?.name[lang || 'en'].toLowerCase()).includes(lowerSearchValue)
) {
return country;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"animated"
],
"author": "George Hope",
"license": "ISC",
"license": "MIT",
"bugs": {
"url": "https://github.com/GeorgeHop/react-native-country-codes-picker/issues"
},
Expand Down