question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New rule: flag nested interactive roles

See original GitHub issue

Nested Interactive Roles

Ensures interactive controls are not nested so they work with keyboards and screen readers

Tags: best-practice, experimental, cat.keyboard

Help text

Ensure interactive controls are not nested.

Selector

a, button, [role="link"], [role="button"]

More info

The code sample below shows a few places where aXe should have flagged nested interactive roles. The developer in this case added a role of link with tabindex, nested a link with role=button and tabindex inside of it, and then put an input with type of image inside. That’s a triple-whammy for nested controls, that we should be able to catch pretty easily since it doesn’t even use click events.

<div role="link" tabindex="40" title="link label">
  <a href="/url-went-here" title="link label" role="button" tabindex="12">
    Link label
    <div class="link-icon">
        <input type="image" alt="add to stop throwing error">
    </div>
  </a>
</div>

Checks

  • none: nested-interactives

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:23 (14 by maintainers)

github_iconTop GitHub Comments

4reactions
stevefaulknercommented, Apr 13, 2018

Nesting which results in duplication of announcements in the aural UI is a problem. For sure there are some examples where the result is sort of OK in some browsers with some AT (unknown unless fully tested), but the cost of teasing those out is worth less than accepting that the non-conforming (in HTML) nesting of interactive elements is an issue that should be flagged as an error.

Here is a neat example of a label/interactive control nesting that causes multiple issues; incorrect name calc and misdirected mouse click. This doesn’t appear to be caught by aXE (version 3.3)

Also interactive nesting conformance errors for marcy’s test page. When the DOM is tested (instead of the HTML code) the errors are reduced from 9 to 7.

3reactions
stevefaulknercommented, Jun 6, 2020

@gaurav5430 I suggest your replacement example would fall foul of WCAG 2.1 SC 4.1.2 amongst other SC, as they are interactive UI elements that do not convey a role, if you add an appropriate role to each then you may fall foul of the nesting rules.

are there any guidelines on whether or not to have any nested interactions at all or not in ARIA widgets?

The authoring requirements for use of ARIA in HTML define what roles can be nested within each role.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Be Wary of Nesting Roles - Adrian Roselli
The problem is that not all developers understand that throwing a role="button" onto an element turns it into interactive content (much like ...
Read more >
Nested interactive controls are not announced by screen ...
Focusable elements with an interactive control ancestor (any element that accepts user input such as button or anchor elements) are not announced by...
Read more >
What's New in Axe-core 2021 - Deque Systems
Added 3 new rules (aria-allowed-role, aria-valid-attr, aria-valid-attr- ... Nested interactive controls are not announced by screen readers but.
Read more >
nested-interactive - Accessibility Insights
Ensure interactive controls don't have focusable descendants by separating nested interactive components or styling a single element.
Read more >
Wcag 4.1.2: Nested Interactive Controls Are Not Announced ...
Connect sidecar content should not use nested interactive controls and any interactive control nested ... New rule: flag nested interactive roles #601.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found