-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
[tabs] Fix Arrow key navigation failing when component is rendered in shadow DOM #47178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Netlify deploy previewhttps://deploy-preview-47178--material-ui.netlify.app/ Bundle size report
|
|
|
||
| const list = tabListRef.current; | ||
| const currentFocus = ownerDocument(list).activeElement; | ||
| const currentFocus = getActiveElement(ownerDocument(list)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by adding a getActiveElement utility that recursively traverses shadow roots to find the actual focused
element. The issue was that document.activeElement returns the shadow host instead of the focused element inside
shadow DOM, causing keyboard navigation to fail the role="tab" check.
|
@sai6855 I would mark this as an "enhancement" instead of a "bug". What do you think? We don't claim to support all components inside Shadow DOM. |
closes #47166
Before
https://codesandbox.io/p/sandbox/shadow-dom-test-tabs-component-78x4c8
After
https://stackblitz.com/edit/evlhh47d-8xzn9hbn