-
Notifications
You must be signed in to change notification settings - Fork 530
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
HitsPerPage doesn’t work correctly with routeToState() #5397
Comments
Thanks for the bug report. The issue likely comes from the HitsPerPage component that doesn't pre-select the current refinement, as opposed to the SortBy component. |
Aha, so if I were to have a crack at a PR for this would using SortBy as a guide be the simplest way forward? |
Yes, it would be! |
In addition to not setting the correct value, I've found that the router only updates for changes to the value set at page first load. |
Setting the initial page loaded value can be achieved by:
|
Thanks for writing this workaround @drpeck |
This would still be amazing to have @Haroenv if it's on the cards. Edit: for anyone looking to do this in 2023, there is an example on how to do it now: https://github.com/algolia/instantsearch/blob/master/examples/vue/e-commerce/src/App.vue#L564 Would still be amazing to have it out of the box though as sort-by is. |
This makes it responsive to the URL, as expected like other widgets. fixes #5397 Slight improvement in the HitsPerPage + SortBy tests, as it was relying on Vue state instead of the DOM I wanted both to be exactly the same, but SortBy doesn't have isRefined on the items apparently.
This makes sense, I've just opened a PR which fixes it so you won't need that workaround anymore in the future. |
Too good, thanks! |
* fix(HitsPerPage): compute selected from isRefined This makes it responsive to the URL, as expected like other widgets. fixes #5397 Slight improvement in the HitsPerPage + SortBy tests, as it was relying on Vue state instead of the DOM I wanted both to be exactly the same, but SortBy doesn't have isRefined on the items apparently. * deasync
Bug 🐞
What is the current behavior?
ais-hits-per-page
component as described in the docsMake a sandbox with the current behavior
Sandbox example: https://codesandbox.io/embed/vueinstantsearchv2starter-8jx9i
What is the expected behavior?
The dropdown should reflect the selected option in the URL when you have selected something other than the default and then reloaded the page.
Does this happen only in specific situations?
What is the proposed solution?
Unsure!
What is the version you are using?
v2.1.0
The text was updated successfully, but these errors were encountered: