Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace accented characters with unaccented counterparts #470

Closed
mcallegario opened this issue Sep 6, 2021 · 5 comments · Fixed by #472
Closed

Replace accented characters with unaccented counterparts #470

mcallegario opened this issue Sep 6, 2021 · 5 comments · Fixed by #472
Labels
question Further information is requested

Comments

@mcallegario
Copy link
Contributor

mcallegario commented Sep 6, 2021

I'm submitting a Feature request

Motivation / Use Case

When doing a text filter on the grid with accented characters, it can be frustrating to have an entry like Jose doesn't match Jose in the table (e !== é).

Expected Behavior

This suggestion search engine has the function of replacing accented characters with their unaccented counterparts for quick and easy filtering. You could also put this same function in the ordering.

Other Information

image

function removeAccents(data: string) {
  if (data.normalize) {
    // Use I18n API if avaiable to split characters and accents, then remove
    // the accents wholesale. Note that we use the original data as well as
    // the new to allow for searching of either form.
    return data.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
  }
  return data;
}
@ghiscoding
Copy link
Owner

ghiscoding commented Sep 6, 2021

I'm not really sure that I want to address this one, it is normal for the Filters to be strict equal. I understand what you mean since I'm a French Canadian but still Jose is not the same as José, they are 2 different and distinct values.
The only possible way that I would accept in doing this change would be through a new flag in the Grid Options (maybe ignoreAccentOnStringFilter) but then does that even work for other language that can have accents or is that only working for Latin language? Also worth to know that searching for this normalize on MDN does say that it isn't supported by all Internet Explorer (IE11 included so just keep that in mind)

@ghiscoding ghiscoding added the question Further information is requested label Sep 6, 2021
@mcallegario
Copy link
Contributor Author

I also find the option of a new flag in the grid options very good (ignoreAccentOnStringFilter)
Yes, the idea works for all accented characters. Regarding "normalize", there are other solutions that are also compatible with IE11 (https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript/53957849#53957849)

ghiscoding-SE pushed a commit that referenced this issue Sep 7, 2021


- closes #470
- add a Grid Option to filter text by ignoring any accent by normalizing the text, the option is set to false by default
ghiscoding added a commit that referenced this issue Sep 7, 2021
feat(filters): option to ignore accent while filtering text, closes #470
@ghiscoding
Copy link
Owner

ghiscoding commented Sep 9, 2021

@mcallegario
Everything is now available in the new release v0.17.0, check it out to see all new features/fixes

Cheers and thanks for all feedback ⭐

@mcallegario
Copy link
Contributor Author

Yes, it's working perfectly, thank you very much.
I also took advantage of and implemented these changes in the sorting routine code
image

@ghiscoding
Copy link
Owner

Please make a Pull Request if you want the changes to be merged into the lib. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
2 participants