⛄Snowberb⛄ – 11-04 Jan 30

I am trying to make a local insensitive search with accents, I want to make a match between option and optión. Right now, if I type optio, both results show, but if I type the next letter, the accented result doesnt show. Here's the code
S
Sniberb443d ago
const filteredOptions = options.filter(({ label }) => {
const NORMALIZE_FORMAT = 'NFD';
const normalizedLocalSearch = localSearch.toLowerCase().normalize(NORMALIZE_FORMAT);
const normalizedLabel = label.toLowerCase().normalize(NORMALIZE_FORMAT);

return (
!normalizedLocalSearch ||
(isMultiple
? normalizedLocalSearch
.split(',')
.some((substring) => normalizedLabel.includes(substring.toLowerCase().normalize(NORMALIZE_FORMAT)))
: normalizedLabel.includes(normalizedLocalSearch))
);
});
const filteredOptions = options.filter(({ label }) => {
const NORMALIZE_FORMAT = 'NFD';
const normalizedLocalSearch = localSearch.toLowerCase().normalize(NORMALIZE_FORMAT);
const normalizedLabel = label.toLowerCase().normalize(NORMALIZE_FORMAT);

return (
!normalizedLocalSearch ||
(isMultiple
? normalizedLocalSearch
.split(',')
.some((substring) => normalizedLabel.includes(substring.toLowerCase().normalize(NORMALIZE_FORMAT)))
: normalizedLabel.includes(normalizedLocalSearch))
);
});
UU
Unknown User442d ago