Repair filtering by clearing pagination pointers #39
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The pagination-pointer state
cursors
that is currently being set withsetCursors
, seems to be the culprit when it comes to how the filtering breaks sometimes.This can easily be tested by navigating back and forth on any product archive that has pagination available - followed by entering a search.
A search, or a filtering of the products at this point, will return a data object with 0 products. Odd behaviour also occur, if a filtering is attempted, while not on the first page of any search/filtering result.
By unsetting the navigation pointer state in this side-effect, and by adding the sortKey state to the dependency array, we can fully reset the search archive every time a filter is changed, or a new search is entered.