-
Notifications
You must be signed in to change notification settings - Fork 13.5k
bug: adding aria labels to host and input element inside shadow root causes issues with nvda #23213
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
Comments
Thanks for the issue. Can you please clarify what issue this is causing in your application? Adding these attributes on the host is required for VoiceOver to work properly: https://github.com/ionic-team/ionic-framework/blob/master/.github/COMPONENT-GUIDE.md#example-components-2 Additionally, since |
I haven't yet decided to use Ionic in my own application, because I was reviewing the code for possible accessibility issues first. (Flawless accessibility is a must for any third-party front-end components that I use.) But I verified that the accessibility tree for the ion-toggle documentation page, as rendered by Chromium-based Edge on Windows, includes nodes for both the host element and the child input element. Both of these accessibility nodes have the role for a toggle button, but only the child one is marked as focusable. Meanwhile, the NVDA screen reader only presents the parent (host) element in its browse mode. So there isn't a single, canonical accessible element. This ambiguity is bound to cause problems. For example, if I navigate to the "Blueberry" toggle with NVDA's find command, NVDA puts its cursor on the parent element, and the child doesn't get the keyboard focus. Then if I press Tab, the focus doesn't move to the next toggle as expected, but somewhere else entirely. |
Could you provide a code sample of the issue with steps to reproduce? Our testing with NVDA did not present these kinds of issues so I am interested in learning more about how we can improve |
Rather than write my own code sample, I'll give steps for reproducing the problem using the ion-toggle documentation page.
These steps expose two problems:
I've verified that neither of these problems happen with bare HTML checkboxes. |
Thanks for the clear instructions. I was able to reproduce the behavior. I definitely agree that this is undesirable behavior, though the process to fix this is not very clear cut. What NVDA DoesWhen you press "X", NVDA grabs the first checkbox/toggle. In this case, it sees If we remove ChromiumChromium considers checkboxes, radios, buttons, and text inputs all focusable via keyboard input. So when you press "Tab" on a page containing an WebKitWebKit considers text inputs focusable, but does not consider checkboxes, radios, and buttons focusable via keyboard input. So when you press "Tab" on a page containing an Potential SolutionUnfortunately, we cannot just remove the host I need to test this idea out of course, but this could be a potential path forward. Let me know if you have any questions. Thanks! |
I have an alternative hypothesis about why the toggle isn't accessible with VoiceOver on iOS when you don't put the ARIA attributes on the host element. When you tap on the toggle component, VoiceOver does a hit test to determine which accessible object it should announce. If the host element is a div or span without any ARIA attributes, then that hit test probably lands on one of the child elements. And I wouldn't be surprised if the hit test ends up on the visible label rather than the hidden input element. So, what happens if you remove the ARIA attributes from the host, and add the aria-hidden flag to all children other than the input element? I don't have an iPhone handy, and I haven't yet set up an Ionic dev environment, so I can't easily test this myself. Thanks a lot for taking the time to look at this. So many developers seem to just ignore accessibility problems. It's encouraging to know that the Ionic team is really trying to get accessibility right. (Yes, accessibility matters a lot to me, not only as a developer but as a blind person.) |
Ah that's an interesting idea. I am hoping to have some time in the coming days to look at this, so I will test that idea out. I also reached out to some contacts on the WebKit team at Apple to see if they could clarify what is going on under the hood. Thanks for opening this issue. We really appreciate any community feedback on how we can improve the accessibility of our components! |
Hi there, We are proposing some changes to form components that seek to resolve this issue. We would love your feedback on these proposed changes! You can read more about the changes and leave comments here: #25660 |
Thanks for the report. In Ionic 7.0 we will be introducing a new The work for this was completed in #26357, so I am going to close this issue. We will have a public beta period in the future for developers to test and provide feedback on Ionic 7. Please let me know if there are any questions. |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Ionic version:
[ ] 4.x
[x] 5.x
I'm submitting a ...
[x] bug report
[ ] feature request
Current behavior:
The ion-toggle component sets ARIA attributes, such as role and aria-checked, on both the checkbox input element and its container. This means there's more than one switch in the accessibility tree, and only the inner switch can actually receive focus or otherwise handle programmatic interaction from assistive technologies.
Expected behavior:
Only the checkbox input element should have these ARIA attributes. The container should have no ARIA attributes, like most HTML container elements.
Steps to reproduce:
This issue can be seen on the online documentation page for the ion-toggle component.
The text was updated successfully, but these errors were encountered: