nrkno / core-components

Accessible and lightweight Javascript components
https://static.nrk.no/core-components/latest/
MIT License
117 stars 10 forks source link

fix(core-suggest): adjust filter case to allow to filter for empty string #749

Closed skjalgepalg closed 1 year ago

skjalgepalg commented 1 year ago

This PR fixes built-in filtering of static content in core-suggest

Previously, when clearing the input to empty value '', this would parse as falsy and no reset/re-filtering would take place. By changing the case to self.input.value != null we maintian filtering for null or undefined but allow for filtering using other falsy values like '', 0, NaN.

Note that being an input, the value will be cast to a string, and so the effective change will only be to allow for filtering by empty string. e.g. NaN would actually be 'NaN' and as such a perfectly valid string to filter by.

Resolves #748