Fix search dialog focus trap and nested result links - #7
Merged
Conversation
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>
11 tasks
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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.
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 theEschint 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.htmla result fordocs/src/configuration.htmlresolved 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 onSearchLitegets it, including the one insphinx-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
Checklist
make lint)make test)