Closed simon-stewart closed 2 years ago
To get it to work for searchs with accented characters and accented items, you can add:
const removeDiacritics = function(str) { return str .normalize('NFD') .replace(/[\u0300-\u036f]/g, '') }
and apply this in lines doing searches using indexOf such as
const idx = removeDiacritics(item.label).toLowerCase().indexOf(removeDiacritics(lookup).toLowerCase());
and
if (removeDiacritics(item.label).toLowerCase().indexOf(removeDiacritics(lookup).toLowerCase()) >= 0) { items.appendChild(this.createItem(lookup, item)); if (this.options.maximumItems > 0 && ++count >= this.options.maximumItems) break; }
Thank you!
To get it to work for searchs with accented characters and accented items, you can add:
const removeDiacritics = function(str) { return str .normalize('NFD') .replace(/[\u0300-\u036f]/g, '') }
and apply this in lines doing searches using indexOf such as
const idx = removeDiacritics(item.label).toLowerCase().indexOf(removeDiacritics(lookup).toLowerCase());
and
if (removeDiacritics(item.label).toLowerCase().indexOf(removeDiacritics(lookup).toLowerCase()) >= 0) { items.appendChild(this.createItem(lookup, item)); if (this.options.maximumItems > 0 && ++count >= this.options.maximumItems) break; }