Skip to content

docs(search): Render site search with Pagefind's prebuilt components - #1203

Merged
yurishkuro merged 2 commits into
jaegertracing:mainfrom
ysh-bot:search-pagefind-component-ui
Nov 21, 2026
Merged

yurishkuro merged 2 commits into
jaegertracing:mainfrom
ysh-bot:search-pagefind-component-ui

Conversation

@ysh-bot

@ysh-bot ysh-bot commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator

Which problem is this PR solving?

Description of the changes

Pagefind already writes a prebuilt set of web components into the site on every build. The navbar search box, its popup and the results page now use those components. The site keeps a glue script, about a quarter of the size of the script it replaces, for what the components have no setting for.

  • The search defaults to the docs version of the page the reader is on, plus the project pages, as before.
  • The popup states its result count and scope, shows the docs version of each result, and links to the results page and to a search of all versions.
  • The results page states its scope, shows the docs version of each result, keeps the version menu, and offers a search of all versions when a version has no results.
  • The results page searches in place as the reader types, and keeps the address bar in step with the query and the version, so a copied link or a reload shows the same search.
  • The popup follows the light or dark theme of the page.

Decisions worth a look

  • Enter opens the highlighted result. The component highlights the first result and Enter opens it; before, Enter opened the results page unless the reader had moved to a result with the arrow keys. Overriding this would contradict the highlight that the component shows.
  • The component bundle loads on every page. That is 41 KB of script and 7 KB of stylesheet, compressed. Before, nothing loaded until the reader focused the search box. This is the cost of using the components as shipped.
  • A version that the index does not hold is searched as given. A link with such a version shows only project pages. The fallback to the latest version, with its note, is gone, because every version the site links to is indexed.
  • The count and both links sit in one line at the top of the popup. Before, the count was at the top and the links at the bottom.

Limitations

  • The links in the popup are reachable by mouse only, because Tab closes the popup.
  • A search that is still pending when the reader dismisses the popup can reopen it. Fix search popup dismissal, duplicate pagination, and version scoping #1170 fixed this in the hand-written code; the component has the same race and the fix belongs upstream.
  • More results load as the reader scrolls the results page; there is no "Show more results" button.
  • Ctrl+K or Cmd+K now focuses the search box. The component binds it, and the hint for it is hidden.
  • The site shows no search box when it is served without a search index.

Tests

The browser tests are rewritten against the component markup. They assert the version scope through the result links instead of the status text alone, and they cover the popup summary and its links, the results page status, the version badges, the address bar, the version menu, and Enter in the mobile sidebar search box.

Six tests are removed with the code they covered: the three "pending navbar search stays closed" cases, "a late bundle error does not reopen a dismissed popup", "Escape keeps the popup closed when pending result data arrives", and "rapid Show more clicks do not duplicate or skip results". The first five have no replacement, per the dismissal limitation above. The last one has none because the button is gone.

How was this change tested?

1. ✅ Browser tests, including the Content-Security-Policy check

Steps and output

From the repository root:

$ npm run test:browser
  21 passed (10.1s)

The run includes the three CSP cases, which load /, a docs page and the results page under the policy in netlify.toml and fail on any blocked resource. The test for Enter in the mobile sidebar search box fails when the fix it covers is removed.

2. ✅ Repository checks

Steps and output

From the repository root:

$ npm run build
$ npm run check:format
All matched files use Prettier code style!
$ npm run check:spelling
CSpell: Files checked: 791, Issues found: 0 in 0 files.
$ npm run check:links:internal
tested 525 documents
$ npm run check:dev-links
Link conventions hold in content/docs/v2/_dev

Checklist

The tests are browser tests, and the checks that ran are listed above.

AI Usage in this PR (choose one)

See AI Usage Policy.

  • None: No AI tools were used in creating this PR
  • Light: AI provided minor assistance (formatting, simple suggestions)
  • Moderate: AI helped with code generation or debugging specific parts
  • Heavy: AI generated most or all of the code changes

🤖 Generated with Claude Code

yurishkuro and others added 2 commits November 20, 2026 19:36
The navbar search box, its popup and the results list were hand-written
on Pagefind's JavaScript API, which left the site to maintain a combobox,
debouncing, request cancellation and pagination. Pagefind ships web
components that do the same job, so the site now uses those and keeps
only a glue script for what they have no setting for: the docs version
that a search covers, and the links between the popup and the results
page.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Yuri Shkuro <github@ysh.us>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Yuri Shkuro <github@ysh.us>
@yurishkuro
yurishkuro merged commit 3e57ed5 into jaegertracing:main Nov 21, 2026
9 checks passed
@yurishkuro
yurishkuro deleted the search-pagefind-component-ui branch November 21, 2026 00:50
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.

2 participants