You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 35a38d8
Browse filesBrowse the repository at this point in the historyBrowse files
authored
fix(aria-required-children): explain presentational children that cannot be ignored (#5407)
Makes the `aria-required-children` failure name the attribute that stops
a `role="presentation"`/`role="none"` child from being ignored.
As #4833 describes, this fails correctly, because `tabindex="-1"` means
the presentational role is not applied:
```html
<div role="grid">
<div role="presentation" tabindex="-1">
<div role="row"><div role="columnheader">foo</div></div>
</div>
</div>
```
but the message blamed the role instead of the attribute:
```
before: Element has children which are not allowed: [role=presentation]
after: Element has presentational children which cannot be ignored because of [tabindex]
```
Changes in `aria-required-children-evaluate.js`:
- `isPresentationalConflict()`: the owned element has an explicit
`presentation`/`none` role, plus the global ARIA attribute or `tabindex`
that `getOwnedRoles()` already records as the reason it was kept
- when every unallowed child is such a conflict, the new
`unallowedPresentational` message lists those attributes (`[tabindex]`,
`[aria-live]`, …)
- when they are mixed with other unallowed children, `unallowed` is kept
and their selector includes the attribute:
`[role=presentation][tabindex], [role=tabpanel]`
- `aria-busy-fail` keeps priority, and a natively focusable child such
as `<button role="presentation">` keeps the current message, also when
it has `tabindex` or a global ARIA attribute: removing the attribute
would not make its role apply
`locales/_template.json` is regenerated in the same commit.
Tests (`test/checks/aria/required-children.js`), asserting `messageKey`
and `values` rather than the message text (#5357):
- the issue's grid example: `unallowedPresentational`, `[tabindex]`
- `role="none"` with `aria-live`: `unallowedPresentational`,
`[aria-live]`
- a presentational child with `tabindex` next to a `tabpanel`:
`unallowed`, `[role=presentation][tabindex], [role=tabpanel]`
- `<button role="presentation">`: `unallowed`, `[role=presentation]`
- `<button role="presentation" tabindex="-1">` and `<button role="none"
aria-label="x">`: `unallowed`, `[role=presentation]` / `[role=none]`
Verified locally: the first three fail on `develop`
(`[role=presentation]` / `[role=none]` with `unallowed`) and pass with
the fix. Dropping the attribute guard in `isPresentationalConflict()`
makes the fourth fail. Prettier, eslint, build (generated files
committed), tsc, the unit, integration and virtual-rule suites,
`test:act` and `test:apg` in Chrome pass.
AI disclosure: this PR was written with Claude Code.
Closes: issue #4833
_Written by Claude Code (AI assistant) on behalf of @namespaceMarcello,
who directs this work._
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Chris Hutchins <chris.hutchins@deque.com>
Copy file name to clipboardExpand all lines: lib/checks/aria/aria-required-children.json
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,7 @@
28
28
"singular": "Required ARIA child role not present: ${data.values}",
29
29
"plural": "Required ARIA children role not present: ${data.values}",
30
30
"unallowed": "Element has children which are not allowed: ${data.values}",
31
+
"unallowedPresentational": "Element has presentational children which cannot be ignored because of ${data.values}",
31
32
"aria-busy-fail": "Element has children which are not allowed: ${data.values}; Having aria-busy=\"true\" does not allow children with roles that are not allowed"
Copy file name to clipboardExpand all lines: locales/_template.json
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -536,6 +536,7 @@
536
536
"singular": "Required ARIA child role not present: ${data.values}",
537
537
"plural": "Required ARIA children role not present: ${data.values}",
538
538
"unallowed": "Element has children which are not allowed: ${data.values}",
539
+
"unallowedPresentational": "Element has presentational children which cannot be ignored because of ${data.values}",
539
540
"aria-busy-fail": "Element has children which are not allowed: ${data.values}; Having aria-busy=\"true\" does not allow children with roles that are not allowed"
0 commit comments