⛄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
Sniberb
Sniberb474d 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))
);
});
Unknown User
Unknown User473d ago
Message Not Public
Sign In & Join Server To View