Skip to content

Commit

Permalink
Update autoComplete.js to work with special characters fixes thoughtw…
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcflopes authored Dec 14, 2023
1 parent 83080da commit 4fb42b7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/util/autoComplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const AutoComplete = (el, quadrants, cb) => {
appendTo: '.search-container',
source: (request, response) => {
const matches = blips.filter(({ blip }) => {
const searchable = `${blip.name()} ${blip.description()}`.toLowerCase()
return request.term.split(' ').every((term) => searchable.includes(term.toLowerCase()))
const searchable = `${blip.name().toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '')} ${blip.description()}`.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '')
return request.term.split(' ').every((term) => searchable.includes(term.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '')))
})
response(matches.map((item) => ({ ...item, value: item.blip.name() })))
},
Expand All @@ -47,8 +47,8 @@ const AutoComplete = (el, quadrants, cb) => {
$(el).radarcomplete({
source: (request, response) => {
const matches = blips.filter(({ blip }) => {
const searchable = `${blip.name()} ${blip.description()}`.toLowerCase()
return request.term.split(' ').every((term) => searchable.includes(term.toLowerCase()))
const searchable = `${blip.name().toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '')} ${blip.description()}`.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '')
return request.term.split(' ').every((term) => searchable.includes(term.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '')))
})
response(matches.map((item) => ({ ...item, value: item.blip.name() })))
},
Expand Down

0 comments on commit 4fb42b7

Please sign in to comment.