[nested-interactive] fails also for not interactive nested elements
See original GitHub issueProduct: axe-core
Expectation:
To be able to use
<div role="button">
pass
<button role="presentation"></button>
</div>
PS: Any way of making the button “not interactive” would be ok for us…
PPS: We tried also added aria-hidden="true"
and tabindex="-1"
but all failed the test
Actual:
It fails with a violation of nested-interactive
.
Motivation:
The div
is in reality a custom element to replace an actual button.
However, as we can’t extend a native button we need to wrap it.
To still be able to support integration with a native form around we put a “hidden” button in there which gets programmatically pressed when needed.
I added a failing test https://github.com/dequelabs/axe-core/pull/2905
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Nested interactive controls are not announced by screen ...
Nested interactive controls are not announced by screen readers. Rule ID: nested- ... Interactive control elements must not have focusable descendants.
Read more >HTML Validation: Why is it not valid to put an interactive ...
I am trying to understand that even if I use this workaround, is it fundamentally wrong to have nested interactive elements? is it...
Read more >Accessibility rule: Interactive controls must not be nested
Screen readers do not announce nested interactive controls. ... Ensure that no focusable child elements are present in any interactive controls. Learn more:....
Read more >Interactive components not working when nested inside a ...
Hello, I found out that if i create an interactive component (ex: Button), and place it inside a a main component (obsiously as...
Read more >nested-interactive - Accessibility Insights
Fail. An element with role="button" has a link as part of the text. Screen readers will not read the link.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@exah I’d very much recommend Steve’s suggestion of styling the option, instead of using a “presentational” checkbox. This nested-interactive rule finds things that behave inconsistently. So in some screen readers you will get the element announced, and in others you won’t. Putting tabindex=“-1” isn’t enough to have it be ignored everywhere consistently. Users can still focus elements with tabindex=“-1” by tabbing it. Even screen reader users will do this when they touch the screen of their phone. You’d have to disable the input to prevent that, and then put role=none on it to avoid the screen readers that do handle nested interactive elements picking up the checkbox by mistake.
Interesting. So now that I see what you’re doing I think the input shouldn’t be there in the fist place. My guess is that you’re trying to create a multi-selection listbox similar to the example here https://www.w3.org/TR/2017/WD-wai-aria-practices-1.1-20170628/examples/listbox/listbox.html#ex2_label. Since the
input
has no accessible name and is not suppose to be focusable itself, then you’re probably using it just for the look of a checkbox. So ya, you’re going to have to go through a ton of hoops to get that to work without causing problems for screen reader users (by addinghidden
) and keyboard users (preventing tab).It would be better to remove the checkbox input and just add a checked style to the selected option.