search-ui
search-ui copied to clipboard
isFilterable={true} breaks when searching on a number
Describe the bug
When using a <Facet isFilterable={true} /> on a field mapped to NUMBER results on.
Uncaught TypeError: str.normalize is not a function
To Reproduce Steps to reproduce the behavior:
- Set
isFilterable = trueon a<Facet/> - Enter any value on the search field
Expected behavior The list of values should be filtered to the value entered
Packages:
"@elastic/react-search-ui": "^1.16.0",
"@elastic/react-search-ui-views": "^1.16.0",
"@elastic/search-ui-app-search-connector": "^1.16.0"
Culprit I believe that the problems resides on a helper that has the following code
export const accentFold = (str = "") => str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
Possible Solution
We should either check if typeof str === 'string before running str.normalize("NFD") or try to cast to string if possible.
thanks for the bug report. Will look into it!
@joemcelroy, I could work on this as well if you want.
even better. happy to accept a PR fix, @renemroger!