algolia / instantsearch-ios

⚑️ A library of widgets and helpers to build instant-search applications on iOS.
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/ios/
Apache License 2.0
591 stars 55 forks source link

InstantSearch iOS Numeric Range Iteractor/Connector not refreshing when searcher search changed #225

Open DrikABrak opened 2 years ago

DrikABrak commented 2 years ago

Describe the bug πŸ› Problem with NumberRangeInteractor and NumberRangeObservableController When an initial search is done, the right values are found. But after, if I am doing another search with a different text, the range does not change!!

Expected behavior πŸ’­ The new query is taken into account for the new values of the range

Environment:

Additional context For a marketplace type application on iOS, I am adding functionalities such as selectable segment, hierarchical categories, dynamic facets and a Range Slider for the price. I also have a search bar for searching. Works well for all EXCEPT the Range Slider. When an initial search is done, the right values are found. But after, if I am doing another search with a different text, the range does not change!!

I have this numericRangeInteractor that I connected to my FilterState and searcher, and finally my controller (NumericRangeController) For info I have connector my Numeric Range Interactor this following way take the traditional RangeSlider as my slider.

        priceNumberRangeInteractor.connectFilterState(filterState, attribute: "c_price_int")
        priceNumberRangeInteractor.connectSearcher(searcher, attribute: "c_price_int")
        priceNumberRangeInteractor.connectController(priceNumberRangeController)

Any idea? I tested everything. Thanks !!!

VladislavFitz commented 2 years ago

Hi @DrikABrak ,

This is an expected behaviour. Both NumberRangeInteractor and NumberInteractor uses only the initial bounds value from facet stats and use them to setup widget bounds. That is to say, they shows the bounds for the entire set of hits.

Please note that the bounds values change on each search response and represent the bounds for the current set of hits .

Let's say you have a numeric facet value controlled by a range slider.

That's why the numeric interactors only take into account the bounds for the entire set of hits and not updated on each result. If you want to implement a custom behaviour for your range widget, you can make it conform to Boundable protocol and connect it to the HitsSearcher using the connect method. Then, you can implement the behaviour your expect in the applyBounds method implementation.

Let me know if you have any further question.