Skip to content

New rule: flag nested interactive roles #601

@marcysutton

Description

@marcysutton

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

Metadata

Metadata

Assignees

Labels

best practicerulesIssue or false result from an axe-core rule

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions