fix: support numeric filter when search query is empty #37
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thanks for this great package! Everything worked nicely for me, except for one thing. Numeric filters would always yield 0 results. However, the filter would work if there was a search query specified. So, if I narrowed the results by passing a search query and THEN applied the filter (using RangeInput from react-instantsearch in my case) it would correctly filter those results.
I cloned your demo app (https://github.com/unplatform-io/clientside-instantsearch-demo) to see if it worked correctly there, but that app had the same behaviour.
Steps to reproduce
Solution
There seems to be an issue with ItemsJS when you supply a filter function together with an empty query. So my workaround is to check for an empty query, and in that case apply the filter afterwards instead.
Everything works for me now.