-
Notifications
You must be signed in to change notification settings - Fork 532
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
fix(createURL): correctly remove page in state #4679
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 0767ed8:
|
In the future we should rely on getWidgetSearchParameters IMO, although at the moment that doesn't reset the page either (otherwise it doesn't work when pagination or infinite hits isn't the last widget). Maybe |
@Haroenv That was pretty much my approach too when I created my hacky workaround but thinking about it more, you want pretty much every facet in the URL except pagination so I think a "reset pagination" type method is the best way to handle it. Forked & updated the code sandbox to show it working in action with routing (super rough, don't judge me :D) https://codesandbox.io/s/instantsearchjs-forked-pgrci?file=/src/app.js |
While this PR looks good to me, could you rephrase what you said? |
If you check the implementations of getWidgetSearchParameters, you'll see that none of them reset the page. That's because the actual page reset logic is done in the index widget's change listener on the helper. That means that even if we use getWidgetSearchParameters for createURL and refine, we still would have to reset the page after retrieving the state. It could be quite interesting longer-term to use a createURL based on UIState alone though, as well as relying on uiState alone for refine. I think it should be possible in theory, but will have breaking changes for non-builtin widgets relying only on the helper state. Maybe in a major version? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation. That sounds like an interesting approach, but as you said, in a major version.
This PR looks good to me.
Summary
createURL didn't reset the page because it uses SearchParameter methods vs. helper methods which get the page reset automatically.
Result
fixes algolia/vue-instantsearch#932
all createURLs now reset the page as expected