Bug 🐞
ais-hits-per-page component as described in the docsSandbox example: https://codesandbox.io/embed/vueinstantsearchv2starter-8jx9i
The dropdown should reflect the selected option in the URL when you have selected something other than the default and then reloaded the page.
Unsure!
v2.1.0
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.
E.g. Page loads at /search?hitsPerPage=20, when you select 10 the url changes to /search?hitsPerPage=10, when you select 20 again the url changes to /search.
Setting the initial page loaded value can be achieved by:
<ais-hits-per-page :items="hitsPerPageOptions" />
and
data(){
return {
hitsPerPageOptions: [
{ label: "8 results", value: 8, default: this.$router.currentRoute.query.hitsPerPage != 16 },
{ label: "16 results", value: 16, default: this.$router.currentRoute.query.hitsPerPage == 16 }
]
}}
Thanks for writing this workaround @drpeck