search-ui icon indicating copy to clipboard operation
search-ui copied to clipboard

isFilterable={true} breaks when searching on a number

Open renemroger opened this issue 3 years ago • 3 comments
trafficstars

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:

  1. Set isFilterable = true on a <Facet/>
  2. 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.

renemroger avatar Aug 03 '22 00:08 renemroger

thanks for the bug report. Will look into it!

joemcelroy avatar Aug 03 '22 12:08 joemcelroy

@joemcelroy, I could work on this as well if you want.

renemroger avatar Aug 03 '22 17:08 renemroger

even better. happy to accept a PR fix, @renemroger!

joemcelroy avatar Aug 03 '22 18:08 joemcelroy