fix(docs/search): handle search index loading and failure states#3184
Draft
Anuragp22 wants to merge 1 commit into
Draft
fix(docs/search): handle search index loading and failure states#3184Anuragp22 wants to merge 1 commit into
Anuragp22 wants to merge 1 commit into
Conversation
…t ready Previously performSearch rendered "No results found" while the MiniSearch index was still loading, which is misleading on slow networks. Track the last query as pendingQuery and replay it from fetchSearchIndex once the index is ready; render a distinct "Failed to load search index" message on fetch error so the loading message doesn't persist indefinitely. Fixes HeyPuter#3180.
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.
Summary
Fixes #3180.
Open question for review
The failure-state message is not in the issue description but is a necessary consequence of the loading-state change. Without it, a failed
fetchSearchIndexwould leave "Loading..." showing forever. Open to dropping or rephrasing if a different approach is preferred.The pre-existing
openSearchUI()call toupdateSearchResults([])(which renders "No results found" on open before any typing) is out of scope and untouched.Test plan
src/docs/src/assets/js/search.jshas no existing unit tests, so this change is verified manually. Built and served locally (npm run build && npm run serveinsrc/docs):/index.jsonloads: "Loading search index..." appears, results auto-render when the index lands without retyping./index.jsonreturning 404: brief "Loading..." then "Failed to load search index. Please refresh."