algolia / vue-instantsearch

👀 Algolia components for building search UIs with Vue.js
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/vue
MIT License
854 stars 157 forks source link

History router doesn't load all previous pages #1140

Closed lopugit closed 2 years ago

lopugit commented 2 years ago

Bug 🐞

What is the current behavior?

When visiting a history router url such as ?index%5Bpage%5D=3, previous pages are not included in the items array

Make a sandbox with the current behavior

Template: https://codesandbox.io/s/trusting-sea-opgwlw

What is the expected behavior?

When using ais-infinite-hits all items should be loaded from previous pages if in conjunction with history router

Does this happen only in specific situations?

What is the proposed solution?

Take into account page query value

What is the version you are using?

algoliasearch 4.14.2 vue-instantsearch 4.4.2

Always try the latest one before opening an issue.

dhayab commented 2 years ago

Hi, the widget interprets the query parameter by only fetching the results starting from the specified page when accessing the page. It would be problematic to implicitly load all the previous pages, if for example, we visit an URL which specifies a high page number.

We provide 2 methods of showing results from previous pages.

You can add :show-previous="true" (API reference) to your widget, which will add a button that will allow the users to go back to those results, page by page

You can also change how the widget caches its results. By default it uses an in-memory cache, which adds new results when paginating to a single list. This cache is released when leaving the page. Instead, you can take advantage of the session storage cache, allowing you to leave the page, and when you go back to it, all the previously cached results will be fetched from sessionStorage. You can check out the cache attribute in the API reference.

I'll close this issue, but feel free to comment if you have any more questions.