Skip to content

False positives for containers with role="presentation" #274

@TrevorBurnham

Description

@TrevorBurnham

Prompted by mui/material-ui#18106

If you set role="presentation" on any container element whose descendants have a semantic meaning, you'll get the warning:

This element's role is "presentation" but contains child elements with semantic meaning.

For example, this markup triggers the warning:

<div role="presentation">
  <a href="http://example.com">Link</a>
</div>

The sniff that generates the warning seems to be based on an overly broad interpretation of F92:

This failure occurs when a role of presentation is applied to an element whose purpose is to convey information or relationships in the content.

The example given is that a <table> element with role="presentation" no longer functions as a table. The important thing is the element itself, not its descendants. The WAI-ARIA spec specifically states that when you set role="presentation" on an element,

The roles, states, and properties of each descendant element remain visible to assistive technologies


I recommend that the sniff should be rewritten to apply more narrowly. At the very least, it should ignore elements like div and span that already have no semantic meaning, since setting role="presentation" on those elements has no effect on assistive technologies.

This came up previously as #191 in the context of <svg> elements. /cc @ironikart

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions