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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refining via a range slider can "strand" the user on an empty page of results #4759

Closed
jonprindiville opened this issue May 20, 2021 · 5 comments · Fixed by #4760
Closed

Comments

@jonprindiville
Copy link

🐛 Bug description

Some widgets seem to reset the current page if the user refines in such a way that they are no longer looking at a valid page and some do not.

🔍 Bug reproduction

Steps to reproduce the behavior:

  1. Go to https://instantsearchjs.netlify.app/examples/e-commerce/search/Video+Games%2FPC+Gaming/?page=2&hitsPerPage=64 -- here I have a search which returns 66 items and 64 per-page, so this second page has only two items
  2. Refine using the price slider, e.g. set a low maximum bound
  3. Note that the UI leaves you on a page with no results and displays a "sorry" message suggesting you reset the filter; there are results to this search, they are on page one

Live reproduction:

Above instructions are a live repro, using one of your demos.

💭 Expected behavior

When I am on page X and I refine to a result set that doesn't fill X pages, I should be taken back to some valid page of the results.

Note that the behaviour described does not happen if you use a widget other than the range slider:

  1. Go to https://instantsearchjs.netlify.app/examples/e-commerce/search/Video+Games%2FPC+Gaming/?page=2&hitsPerPage=64 -- here I have a search which returns 66 items and 64 per-page, so this second page has only two items
  2. Instead of refining using the price slider, this time use the "brand" refinement list, e.g. MSI
  3. Note that you have been relocated to page one instead of being shown the "sorry" message as in the above example

Additional context

This was reported to me regarding our own instantsearch.js-based app, but the reproduction steps I used above are on your own demo to illustrate that the problem does not come from our own implementation.

@Haroenv
Copy link
Contributor

Haroenv commented May 21, 2021

Thanks for writing this issue, it indeed seems like range slider doesn't reset the page as expected when something is refined. The relevant code in connectRange is here:

https://github.com/algolia/instantsearch.js/blob/142660a2bc0ab7212265a9ff6dadf7a7f1081c69/src/connectors/range/connectRange.ts#L347-L362

and here:

https://github.com/algolia/instantsearch.js/blob/142660a2bc0ab7212265a9ff6dadf7a7f1081c69/src/connectors/range/connectRange.ts#L167-L249

I'm pretty sure this bug did not exist in an older version of InstantSearch, but would need to check

@Haroenv
Copy link
Contributor

Haroenv commented May 21, 2021

Still did not find the exact cause, but it was introduced in 9bc6359 / 4.8.0, the last version that does not yet have this bug is 4.7.2

@Haroenv
Copy link
Contributor

Haroenv commented May 21, 2021

It's because in that version, the state is reset instead of the helper, which means the page isn't reset. Making a PR to fix it now

@Haroenv
Copy link
Contributor

Haroenv commented May 21, 2021

I checked, and all the other widgets seem to be implemented correctly, just this one was wrong. Thanks for your report!

@jonprindiville
Copy link
Author

Thanks, @Haroenv!

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

Successfully merging a pull request may close this issue.

2 participants