-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
computeAccessibleName ignores text inside of shadow DOM #768
Comments
Thanks for the report. This makes sense to me intuitively but it's not very clear from the ACCNAME spec. Though this may just be an implementation choice or concern for aria-html i.e. is the shadow tree part of the "textual content" and not just So while this is trivial to fix for this particular issue, I have no idea how this interacts with more complex shadow trees. Seems like this is still of an open issue in ACCNAME (w3c/accname#51 and w3c/accname#20). I would appreciate it if somebody could find out how the shadow DOM fits into into story because the usual DOM APIs for text content or children do exclude it by default. |
It's unfortunate that the accname spec isn't very clear on this. Based on how screen readers actually behave with shadow content, my intuition is that essentially the shadow tree should be traversed in normal tree order (with slots serialized in the order expressed in the shadow DOM, not light DOM). This aligns with their visual presentation as well. |
Would definitely agree here. I think for now we could just walk the shadow tree for textual content and only consider If there are some confirmed reports for at least two screen readers we can consider reading the textual content of the shadow tree. But I'm not comfortable fully applying all semantics to the shadow tree (e.g aria-labelledby). Just concatenating the text content of the shadow tree probably covers most usages of the shadow DOM. |
I've found a related issue (repro) that may be slightly easier to fix. If two elements are co-located in the same shadow root, and one references the other with e.g. dom-accessibility-api/sources/util.ts Line 94 in 98284fd
(
If you test the two demos I provided (here's the other one), you should see that both NVDA on Windows (Firefox and Chrome) and VoiceOver on MacOS (Safari, Chrome, and Firefox) read the button text contents, even the content inside of the shadow root. Ditto for the label+input in the above demo. I'm not sure if it's explicitly specified by the spec, but those screen readers at least (I haven't tested others) can read content inside the shadow DOM. |
Partially addresses eps1lon#768
Thank you for writing this library! It's great to see a battle-tested solution for computing accessible names and descriptions. 🙂
I noticed, though, that when text is inside of the shadow DOM, it appears that
computeAccessibleName
ignores this text. Here is a CodePen to demonstrate.Note that the Chrome Accessibility DevTools show the text inside of the shadow root as well as the text outside of the shadow root, since the browser uses both to compute the accessible name:
In the case of open shadow roots (the most common kind), it should be possible to traverse shadow boundaries and collect the text inside of shadow roots.
The text was updated successfully, but these errors were encountered: