-
Notifications
You must be signed in to change notification settings - Fork 199
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
Added case insensitive filtering in HTML tables #1004
Conversation
Thanks! Case insensitive comparisons can be somewhat tricky, because not in all languages there is a 1:1 correspondence between lowercase and uppercase characters. This is why calling Is there a way in JS to do a case insensitive comparison directly instead? Or at least case folding as described in the blog post? |
I am not sure, but I think that the current approach only changes the "id" filters, right? We also can have other textual columns, and we should have the same matching behavior there. And I think it would be really good if we could get some unit tests for this. There are already some in |
There is a method toLocaleLowerCase which converts the provided string to lower case according to any locale-specific case mappings. There's also a way using normalize as suggested in blog. It may not be exact same as that of case folding, but I think most of the cases would be satisfied. Which one is preferable ? |
Yes, will do the necessary changes.
I found the |
The problem with
Right, these are the unit tests for |
Got it, will add the textual matching test cases soon. I only found two npm packages which do the case folding - @ar-nelson/foldcase and fold-case but they are not popular. Will they work ? |
Hm, this seems more complex than I thought. The two packages you found also only have relatively old releases. The one alternative I found would be to use a regexp with case insensitive matching. We just have to make sure that all the special characters in the search string are escaped. And we should probably create an regexp instance and reuse it for matching across all cells instead of compiling the regexp every time. Do you think that would be doable? |
Yes, will try to do it soon. |
66f2efc
to
86bd1a4
Compare
Please review the changes made. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just minor suggestions!
I like the test with the special character. How about also adding a test with some characters that are special for regexps, in order to test that the escaping properly works? For example, test that ...
does not match anything or so.
Fixes #924 .
Converting strings to lowercase first and then comparing for case insensitive filtering.
Also fixed the Reference error caused by 47cd777. I apologize for my oversight.