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
ariaHideOutside
incorrect behavior inside shadow DOM.
#6133
Comments
Hey, thank you for the issue. Starting with the definition of a modal https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-modal#description
This means everything on the page that is not the modal dialog should be hidden from users. Shadow dom is just an implementation detail of web apps. It shouldn't affect how a user interacts with the application, this extends to modal dialogs. This means that aria-hidden should be applied to everything not directly containing the modal. However, it would appear that because of the shadow dom, we are not detecting that "directly containing" path.
I'd suggest having a look through our issues, we have a few of them related to ShadowDOM support. I think you'll run into more pretty quickly based on some previous investigations done around iframes as well #1472 (comment) |
@snowystinger Thank you for your comprehensive response. Based on the definition of modals and the necessity to make everything on the page, except the modal dialog, inaccessible to users, I've devised a solution that respects these accessibility requirements while considering the unique challenges Shadow DOM presents. The solution aims to ensure that the modal dialog within a Shadow DOM remains accessible while effectively hiding all other content from assistive technologies, as illustrated in your diagram. Here’s how the proposed solution addresses the key points:
This is the only way I had on mind that ensures that the modal stay accessible and not get affected by the inheritance of any parent having Do you think this is a valid approach and doesn't violate any of the guidelines? I already have this PR #6046 ready for review for adding shadow DOM support, and given that my proposed solution is a valid one I can open another one to add the solution proposed above which will mainly have changes for |
Ah, apologies, I did not notice the user names on both. Thank you. |
Provide a general summary of the issue here
Using modal dialogs in a web component that is implemented with Shadow DOM. The
ariaHideOutside
function setsaria-hidden="true"
on the document body, which is incorrectly inherited by elements within our Shadow DOM. That behavior doesn't happen in the case of iframes due to the separate document. I think that this behavior is incorrect as the modal is being used inside of the shadow DOM and shouldn't alter the accessibility state of what is outside the shadow DOM encapsulation.🤔 Expected Behavior?
The expected behavior is that
aria-hidden
should be confined to the scope of the component's Shadow DOM, affecting only those elements and not leaking to the outer document.😯 Current Behavior
The root
body
getsaria-hidden
set totrue
causing all children to be hidden, including what is inside the shadow DOM.💁 Possible Solution
ariaHideOutside
function should check thetargets
argument if any target has a shadow root usinggetRootNode
and in thehide
function we add a condition not to hide the node if it is not inside the shadow DOM boundary.🔦 Context
We use shadow DOM for encapsulation, and when opening a modal inside our app, it results in all contents in the shadow DOM and consumer app to have
aria-hidden
set totrue
.🖥️ Steps to Reproduce
Hopefully, the following illustration can help clarify the issue:
In the above example, the Consuming Application will have
aria-hidden=true
, which will cause everything to inherit the property, and the modal inside the shadow DOM will be hidden.Version
@react-aria/overlays - 3.21.1
What browsers are you seeing the problem on?
Firefox, Chrome, Safari, Microsoft Edge
If other, please specify.
No response
What operating system are you using?
Mac OS
🧢 Your Company/Team
PSPDFKit
No response
🕷 Tracking Issue
No response
The text was updated successfully, but these errors were encountered: