-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[ButtonBase] Shadow Root activeElement resolution #13447
Comments
Does |
This is potentially handled by Although, a similar issue to this one was raised on the WICG/focus-visible polyfill @ WICG/focus-visible#28 |
Do you have a reproduction example? What the use case? |
Sure. https://codesandbox.io/s/8lxr89x2p2 |
@JaiPe Well done with the JSS setup for shadow DOM. In the documentation, I wish we had a demo with an iframe, a popup, and a shadow dom. The fix looks good enough to me. There is a bundle size overhead concern but the fact it's usable within a shadow DOM is a convincing argument. @eps1lon What do you think? |
I wasn't very convinced at first but native buttons do gain a visible focus state within a shadow root so I'd say we improve the polyfill. |
Can I take this one?? |
Actually already got something working locally. I can just tidy it up and add some tests. |
The focusVisible polyfill for ButtonBase components was not resolving targets inside a shadowRoot. Now the activeElement for nested shadowRoots is resolved to add focus visible classes to targets in the shadow DOM.
The focusVisible polyfill for ButtonBase components was not resolving targets inside a shadowRoot. Now the activeElement for nested shadowRoots is resolved to add focus visible classes to targets in the shadow DOM.
The focusVisible polyfill for ButtonBase components was not resolving targets inside a shadowRoot. Now the activeElement for nested shadowRoots is resolved to add focus visible classes to targets in the shadow DOM.
The focusVisible polyfill for ButtonBase components was not resolving targets inside a shadowRoot. Now the activeElement for nested shadowRoots is resolved to add focus visible classes to targets in the shadow DOM. Closes mui#13447
* [ButtonBase] Update focusVisible polyfill for shadowRoots (#13447) The focusVisible polyfill for ButtonBase components was not resolving targets inside a shadowRoot. Now the activeElement for nested shadowRoots is resolved to add focus visible classes to targets in the shadow DOM. Closes #13447 * Modify test to check for shadowRoot behaviour and functionality before simulating it * size-limit
@JaiPe I'm using your codesandbox example example to render an the AppBar component However, I cannot get the click events to work properly. Have you found any solution to this? |
Can you send an updated code sandbox example? |
Hi, here is a fork of your project with the aforementioned component included. In the demo you can see the click's won't work. Not sure how to fix them. I read about it a little (shadow root blocks outer events) but not sure how to fix it. |
Hey. You'll probably need something like this, so the events re-target and React knows about them. React listens at the document level for events (yet events don't bubble out of the shadow root by default). |
fix text-mask#981 issue add small function to find real active element https://medium.com/dev-channel/focus-inside-shadow-dom-78e8a575b73 function from mui/material-ui#13447
When using custom elements with a shadowRoot, the
focusVisibleClassName
is applied to the outer-most custom element, instead of the actual element that is focused within the shadow DOM.Expected Behavior
focusVisibleClassName
should be added to deepest-levelactiveElement
when a shadowRoot is present.Current Behavior
focusVisibleClassName
is applied to the outer-most custom element that is returned fromdocument.activeElement
.Possible Solution
Traverse
activeElement
targets that have a shadowRoot to find the lowest level active element for a given component; or just returndocument.activeElement
if no shadowRoot is present.Following solution appears to work as expected:
The text was updated successfully, but these errors were encountered: