feat(focus-scope): Take shadow DOM elements in consideration for focus management#3838
Open
fbouquet wants to merge 22 commits intoradix-ui:mainfrom
Open
feat(focus-scope): Take shadow DOM elements in consideration for focus management#3838fbouquet wants to merge 22 commits intoradix-ui:mainfrom
fbouquet wants to merge 22 commits intoradix-ui:mainfrom
Conversation
… shadow DOM boundary
…ross the shadow DOM boundary
…ss the shadow DOM boundary
…the shadow DOM boundary
- Add data-radix-menu-sub-trigger attribute to MenuSubTrigger for proper identification - Implement custom event system for explicit submenu closure in shadow DOM contexts - Disable automatic grace timer closure in shadow DOM to prevent premature submenu closing - Use native event coordinates for improved accuracy in shadow DOM environments - Extend grace period to 800ms in shadow DOM to account for coordinate detection limitations - Ensure only one submenu remains open when navigating between multiple subtriggers 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Remove unnecessary empty lines and unused variables - Extract shadow DOM detection into reusable utility function - Simplify coordinate handling by removing unused adjustments - Revert isPointerInGraceArea changes that weren't needed for the fix - Reduce code duplication in shadow DOM detection logic 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
… DOM The logic was unnecessary, and infact, was incorrect, as it was running when _not_ in a shadow DOM
|
Author
|
@chaance, are you the right person to ping for reviewing this PR, or should I ping someone else? 🙏 |
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.
This extends @cpsoinos's PR (#3674) with an additional fix to ensure that shadow DOM elements are properly handled in the context of container with trapped focus.
Before my additional changes, the focus edges in a trapped context were not properly determined, resulting in the user not being able to focus on elements within a shadow DOM if they are after the last interactive element that is not in a shadow DOM. See the screen recording below for an example.
Also adding tests to prevent regression, and a story to showcase the changes.
Before (frenetically hitting Tab just keeps the focus on the "Close" button):
Screen.Recording.2026-04-02.at.19.21.18.mov
After:
Screen.Recording.2026-04-02.at.19.21.56.mov