Skip to content

Fix search dialog focus trap and nested result links - #7

Merged
timkpaine merged 1 commit into
mainfrom
tkp/fix-search-dialog-trap
Sep 8, 2026
Merged

Fix search dialog focus trap and nested result links#7
timkpaine merged 1 commit into
mainfrom
tkp/fix-search-dialog-trap

Conversation

@timkpaine

@timkpaine timkpaine commented Sep 8, 2026

Copy link
Copy Markdown
Member

Description

Four fixes to the search dialog, all reproducible on the deployed yardang docs.

The dialog could not be dismissed. Adopted theme search fields opened it on focus. Closing a dialog restores focus to the element that opened it, so Escape and backdrop clicks reopened it immediately, with no way out. It now opens on click and on Enter or Space, so focus restoration is harmless. This is what made click-away appear broken as well.

Escape needed two presses. Chrome's <input type=search> consumes the first Escape to clear the field, so the Esc hint in the panel was misleading. The dialog now closes on Escape explicitly.

Selecting the query dismissed the dialog. A click whose press landed inside the panel still targets the dialog on release, so dragging past the field's edge to select the query closed it and discarded the search. Click-away now requires the press to have landed on the backdrop too.

Every result 404'd below the documentation root. Records store urls relative to the root but they were used verbatim as hrefs, so from /docs/src/overview.html a result for docs/src/configuration.html resolved to /docs/src/docs/src/configuration.html. Urls are now resolved against the root as the index loads. Fixing it in the engine rather than the dialog means any UI built on SearchLite gets it, including the one in sphinx-fuma.

Checked in Chromium against the live docs with the patched scripts swapped in, at the site root, at /docs/src/overview.html, and under /_previews/klink/ where the documentation root is itself a subdirectory. Click-away is covered for the backdrop, the area below the panel, clicks inside the panel, and selections dragged out of it.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor / code cleanup
  • CI / build configuration
  • Other (describe below)

Checklist

  • Linting passes (make lint)
  • Tests pass (make test)
  • New tests added for new functionality
  • Documentation updated (if applicable)
  • Changelog / version bump (if applicable)

Adopted theme search fields opened the dialog on focus. Closing a dialog
restores focus to the element that opened it, so Escape and backdrop
clicks reopened it immediately and left no way out. Open on click and on
Enter or Space instead.

Chrome's `<input type=search>` consumes the first Escape to clear the
field, so closing took two presses despite the `Esc` hint. Close the
dialog explicitly.

Record urls are relative to the documentation root but were used verbatim
as hrefs, so every result 404'd from a page below the root. Resolve them
against the root as the index loads.

Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

Test Results

20 tests  +3   20 ✅ +3   2s ⏱️ ±0s
 1 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 5c47b4e. ± Comparison against base commit 14a4851.

@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.12%. Comparing base (14a4851) to head (5c47b4e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main       #7      +/-   ##
==========================================
+ Coverage   94.80%   95.12%   +0.31%     
==========================================
  Files           3        3              
  Lines         154      164      +10     
  Branches       10       10              
==========================================
+ Hits          146      156      +10     
  Misses          4        4              
  Partials        4        4              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@timkpaine
timkpaine merged commit 6d10a92 into main Sep 8, 2026
4 checks passed
@timkpaine
timkpaine deleted the tkp/fix-search-dialog-trap branch September 8, 2026 20:09
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.

1 participant