feat: refs #6839 normalize search #936

Merged
jorgep merged 1 commits from 6839-normalizeSearch into dev 2024-11-14 14:06:04 +00:00
1 changed files with 19 additions and 4 deletions
Showing only changes of commit 7224860c5c - Show all commits

View File

@ -34,18 +34,26 @@ const search = ref(null);
const filteredItems = computed(() => {
if (!search.value) return items.value;
const normalizedSearch = normalize(search.value);
return items.value.filter((item) => {
const locale = t(item.title).toLowerCase();
return locale.includes(search.value.toLowerCase());
const locale = normalize(t(item.title));
return locale.includes(normalizedSearch);
});
});
const filteredPinnedModules = computed(() => {
if (!search.value) return pinnedModules.value;
const normalizedSearch = search.value
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '')
.toLowerCase();
const map = new Map();
for (const [key, pinnedModule] of pinnedModules.value) {
const locale = t(pinnedModule.title).toLowerCase();
if (locale.includes(search.value.toLowerCase())) map.set(key, pinnedModule);
const locale = t(pinnedModule.title)
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '')
.toLowerCase();
if (locale.includes(normalizedSearch)) map.set(key, pinnedModule);
}
return map;
});
@ -147,6 +155,13 @@ async function togglePinned(item, event) {
const handleItemExpansion = (itemName) => {
expansionItemElements[itemName].scrollToLastElement();
};
function normalize(text) {
Review

Pasa los acentos o diéresis a letras normales, solicitado por J. Gallego.

Pasa los acentos o diéresis a letras normales, solicitado por J. Gallego.
return text
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '')
.toLowerCase();
}
</script>
<template>