Skip to content

fix(docs/search): handle search index loading and failure states#3184

Draft
Anuragp22 wants to merge 1 commit into
HeyPuter:mainfrom
Anuragp22:fix/3180-docs-search-loading-state
Draft

fix(docs/search): handle search index loading and failure states#3184
Anuragp22 wants to merge 1 commit into
HeyPuter:mainfrom
Anuragp22:fix/3180-docs-search-loading-state

Conversation

@Anuragp22
Copy link
Copy Markdown

Summary

  • Replaces the misleading "No results found" empty state shown when users searched before the MiniSearch index finished loading. The search now shows "Loading search index..." and replays the query automatically once the index is ready.
  • Renders a distinct "Failed to load search index. Please refresh." message on fetch error so the loading state does not persist indefinitely.

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 fetchSearchIndex would leave "Loading..." showing forever. Open to dropping or rephrasing if a different approach is preferred.

The pre-existing openSearchUI() call to updateSearchResults([]) (which renders "No results found" on open before any typing) is out of scope and untouched.

Test plan

src/docs/src/assets/js/search.js has no existing unit tests, so this change is verified manually. Built and served locally (npm run build && npm run serve in src/docs):

  • Normal speed: search results render as before, no flash of loading state.
  • 3G throttle, type before /index.json loads: "Loading search index..." appears, results auto-render when the index lands without retyping.
  • /index.json returning 404: brief "Loading..." then "Failed to load search index. Please refresh."
  • 3G throttle, type then backspace to empty input before the index loads: pending query is cleared, no stale results fire when the index arrives.

…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.
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 28, 2026

CLA assistant check
All committers have signed the CLA.

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.

Add edge case handling for docs search when index hasn't loaded yet

2 participants