Skip to content

fix: make documentation search usable - #9

Merged
smiggleworth merged 1 commit into
mainfrom
fix/website-docs-search
Jul 25, 2026
Merged

fix: make documentation search usable#9
smiggleworth merged 1 commit into
mainfrom
fix/website-docs-search

Conversation

@smiggleworth

Copy link
Copy Markdown
Contributor

Fixes #8.

The docs search trigger now focuses the input when opened by click as well as keyboard shortcut. Search requests are generation-guarded so stale lazy-index loads cannot overwrite newer input, and failures leave a visible retryable state instead of a permanent loading state.

Validation:

  • npm run fmt -- --write src/pages/docs/search.tsx
  • npm run typecheck
  • npm run test:unit
  • npm run check

Copilot AI review requested due to automatic review settings July 25, 2026 17:03
@smiggleworth
smiggleworth merged commit f10f462 into main Jul 25, 2026
2 checks passed
@smiggleworth
smiggleworth deleted the fix/website-docs-search branch July 25, 2026 17:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves the documentation search dialog interaction so it reliably opens/focuses, handles lazy index loading without stale updates, and surfaces a visible failure state instead of getting stuck loading.

Changes:

  • Centralizes “open search” behavior to focus the input for both keyboard shortcuts and trigger clicks.
  • Adds a generation/cancellation guard around the async lazy import to prevent stale searches from overwriting newer input.
  • Introduces an error state UI when loading/search fails.
Comments suppressed due to low confidence (2)

src/pages/docs/search.tsx:35

  • After persisting searchGeneration in state, runSearch still uses ++searchGeneration and compares against searchGeneration as if it were a mutable number. Update the increment/check logic to use the getter/setter (searchGeneration() / setSearchGeneration(...)) so stale async searches cannot clobber newer ones.
  const runSearch = async (value: string) => {
    const generation = ++searchGeneration;
    setQuery(value);
    setError(false);
    if (!value.trim()) {

src/pages/docs/search.tsx:56

  • close() currently mutates searchGeneration directly. Once searchGeneration is stored in component state, increment it via the setter so any in-flight searches see the updated generation and abort correctly.
  const close = () => {
    searchGeneration += 1;
    setOpen(false);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/pages/docs/search.tsx
Comment on lines 12 to +15
const [results, setResults] = state<readonly DocsSearchRecord[]>([]);
const [error, setError] = state(false);
let searchGeneration = 0;

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.

Fix documentation search interaction on the deployed site

2 participants