fix: search results flickering and mixing in explorer#465
Open
pablocampogo wants to merge 2 commits into
Open
Conversation
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.
Fix search results flickering and cross-search value mixing
Summary
The Search view had two visible bugs:
Root causes
useSearchre-ran its full search on every dependency change (including background React Query refetches) and immediately didsetResults(null)+setLoading(true), blanking the panel.setResultsonly afterawait Promise.all(...), which always includes a fullAllOrders()order-book scan — so a fast address lookup was held hostage by the slowest source, leaving the old result on screen.AddressResultwas declared insideSearchResults, giving it a new component identity every render → React remounted (and re-fetched) it on every update, and content-based keys made cards blink on every change.Changes
hooks/useSearch.tsrequestIdguard so stale (superseded) searches can't overwrite newer results or clear the newer search's state.setResults(null)); values are swapped in place when ready.Promise.allSettled+ a final forced publish that also renders the "no results" state.loadingnow means "first search only" (isSearching && !results); later searches update in place. Also exposesisSearching.components/search/SearchResults.tsxAddressResult(andcopyToClipboard) to module scope for a stable component identity, so cards update in place rather than remounting.AddressResultso a stale response can't overwrite a newer address.pages/Search.tsxmt-4to the Related Searches container.Result