Skip to content

Commit

Permalink
feat: search now normalizes nombreFilter and nombreMateria for materi…
Browse files Browse the repository at this point in the history
…as with accent marks
  • Loading branch information
SBen-IV authored and FdelMazo committed Oct 20, 2023
1 parent 7011189 commit e683576
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/components/Materias.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ const Materias = ({ materias, materiaSelected, setCodigoSelected, partialLoading
const shownMaterias = React.useMemo(() => {
return materias
.sort((a, b) => b.reponames.size - a.reponames.size)
.filter((m) =>
nombreFilter
? m.nombre.toLowerCase().includes(nombreFilter.toLowerCase()) || m.codigos.some(c => c.includes(nombreFilter))
: true
)
.filter((m) => {
const nombreFilterNormalizado = nombreFilter.normalize('NFD').replace(/\p{Diacritic}/gu, '').toLowerCase()
const nombreMateriaNormalizada = m.nombre.normalize('NFD').replace(/\p{Diacritic}/gu, '').toLowerCase()
return nombreFilter
? nombreMateriaNormalizada.includes(nombreFilterNormalizado) || m.codigos.some(c => c.includes(nombreFilterNormalizado))
: true
})
}, [materias, nombreFilter]);


Expand Down

0 comments on commit e683576

Please sign in to comment.