Sniberb
Sniberb2y ago

⛄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
2 Replies
Sniberb
Sniberb2y 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))
);
});
reactibot
reactibot2y ago
This thread hasn’t had any activity in 12 hours, so it’s now locked. Threads are closed automatically after 12 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1069573770014101516