fix(webkit): restore focus to the popover trigger's focusable child - #882
Open
gabriel-lisboa-azion wants to merge 2 commits into
Open
fix(webkit): restore focus to the popover trigger's focusable child#882gabriel-lisboa-azion wants to merge 2 commits into
gabriel-lisboa-azion wants to merge 2 commits into
Conversation
focusTrigger() called .focus() on the passthrough <span> wrapper, which is not focusable, so focus fell to <body> on every close. It now focuses the wrapper when the wrapper itself is focusable and its first focusable descendant otherwise.
herbert-julio-azion
approved these changes
Aug 12, 2026
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.
The bug
focusTrigger()called.focus()on the passthrough<span>that wraps aPopover.Trigger. A bare<span>is not focusable, so the call was a no-op and focus fell to<body>every time a popover closed.The cost is paid by keyboard users: after closing a popover,
Tabrestarts from the top of the document instead of continuing from the control that opened it.The fix
Focus the wrapper when the wrapper itself is focusable, and its first focusable descendant otherwise.
FOCUSABLE_SELECTORis hoisted to module scope so the close path andgetFocusableshare one definition rather than keeping two that can drift.Verification
packages/webkit/src/components/overlay/popover/popover.test.tspasses, along with the rest of the browser suite (93 files, 2036 tests). The behaviour is a real-browser one —document.activeElementafter a close — which is exactly the class of thing jsdom returns a no-op for, so it is checked in Playwright Chromium.