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

fix(infiniteHits): fix wrong behavior of showPrevious regarding cachedHits #4725

Merged
merged 1 commit into from
Apr 8, 2021

Conversation

eunjae-lee
Copy link
Contributor

@eunjae-lee eunjae-lee commented Apr 7, 2021

Summary

This PR fixes the wrong behavior of showPrevious and showMore because the functions were created at init with cachedHits. It means showPrevious and showMore always have wrong (empty) cachedHits object. Instead, we need to read from cache every time.

fixes algolia/vue-instantsearch#945

Reproduction of the issue from Vue InstantSearch

https://fyn4y.csb.app/?instant_search[page]=4 (https://codesandbox.io/s/instantsearchjs-forked-fyn4y?file=/src/app.js)

  • Click "Show more results" and you will see more results.
  • Click "Show previous results" and you expect previous hits to be added, but nothing happens.
  • Click "Show previous results" again, and it works now.

And the following is the same example with the InstantSearch.js version from this PR and it works fine:

https://tdmbd.csb.app/?instant_search[page]=4 (https://codesandbox.io/s/instantsearchjs-forked-tdmbd?file=/src/app.js)

Result

showPrevious and showMore work correctly.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 7, 2021

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 64d4e02:

Sandbox Source
InstantSearch.js Configuration

@eunjae-lee eunjae-lee marked this pull request as ready for review April 7, 2021 12:27
@eunjae-lee eunjae-lee requested review from a team, tkrugg and shortcuts and removed request for a team April 7, 2021 12:27
@Haroenv Haroenv merged commit 40b27b6 into master Apr 8, 2021
@Haroenv Haroenv deleted the fix/infinite-hits-cached-hits branch April 8, 2021 08:07
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 this pull request may close these issues.

Aisinstantsearch SSR loadmore and loadprevious not working smoothly
3 participants