Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
DrikABrak opened this issue May 30, 2022 · 1 comment
Assignees

Comments

@DrikABrak
Copy link

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:

  • OS: iOS - SwiftUI
  • Version device: 15.4.1
  • Version SDK Algolia: InstantSearch v7.17.0

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 VladislavFitz self-assigned this Jun 24, 2022
@VladislavFitz
Copy link
Contributor

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.

  • Its initial bounds: 0...5, initial value: 0...5. It looks as follows: 0 |>----<| 5
  • You change the lower slider value to 1. 0 |->---<| 5
  • The value of the filter changes to 1...5, a new search request launched.
  • A new search response received with bounds 1...5
  • In case these new bounds applied to your widget, it now looks as follows: 1 |>---<| 5
  • From this state it's impossible to change the lower range value back to 0 without the complete removal of the filter.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants