Repository navigation
fix: skip hidden controls when trapping focus - #631
Merged
Merged
Conversation
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.
When a highlighted element contains a
visibility: hiddencontrol between two visible buttons, Tab keeps trying to focus the hidden control and never reaches the next button. Shift+Tab gets stuck in the same way.Check each focus candidate's computed visibility so keyboard navigation skips hidden controls while still reaching an explicitly visible descendant of a hidden parent. The existing pointer-events and layout checks are preserved.
driver-hidden-controls-before-after.mp4
The video is a sequence of actual browser screenshots from a standalone consumer in the official E2E harness. Before the fix, three Tab presses leave focus on First action; afterward, Tab reaches Last action and both directions cycle normally.
The two added regressions fail on the original code and pass with this change. The complete focus suite passes in Chromium, Firefox and WebKit. Unit tests, builds, package lint and formatting also pass.
Validation environment
Node 22.23.2, pnpm 11.9.0, Playwright 1.65.0. Firefox uses the pinned revision 1572; Chromium 1248 and WebKit 2370 are existing runtimes rather than the pinned 1254/2388 revisions. Each engine passed all 17 focus tests; this was not a full E2E-suite run. All 812 unit tests and the three workspace builds passed. Native before/after verification used Chromium 156.