Reset the progressive search cache from the received page, not the patched results state - #610
Open
jamiefolsom wants to merge 1 commit into
Open
Reset the progressive search cache from the received page, not the patched results state#610jamiefolsom wants to merge 1 commit into
jamiefolsom wants to merge 1 commit into
Conversation
…e patched results state InstantSearch patches the previous results' state to the current state while a new search is in flight, so comparing states reset the cache to stale hits and merged the real ones into them. A facet arriving in the URL therefore showed as selected without narrowing the list. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FZMB4y5UeksG92wxt7PVXX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
useProgressiveSearchnow decides whether a newly received page starts the hit cache over or appends to it from the results object and its page number, instead of comparingresults._statewith the previous state.Why
InstantSearch re-renders widgets with the previous results while a new search is in flight, and it patches
_stateon that previous results object to the current state (its optimistic UI). Soresults._statedoes not identify the search that produced the hits. When a facet value arrives in the page URL, the facet widgets mount after the first search has been sent; the hook then saw the unfiltered hits stamped with the filtered state, reset its cache to them, and merged the real filtered hits into that. The page showed the facet as selected while listing unfiltered results (performant-software/core-data-places#793).How
utils/ProgressiveSearch.jsaddsgetCacheAction(results, previousResults): skip when there are no results, when the object is the one already processed, or when it is InstantSearch's artificial placeholder; reset when the received page is 0; merge otherwise.dequalcomparison and its in-place deletion ofpagefrom the state objects are gone.Verified
getCacheAction(the package had none before; they run under the rootjest).Flow was not run: the repo's
.flowconfiguses an option the installed Flow version rejects, which predates this change.