Skip to content

Commit 32fe6af

Browse files
dan-tripp-siteimproveJym77carlosapaduarte
authored
"Element with presentational children has no focusable content" (rule 307n5z) - adding examples (#2099)
* invalid-form-field-value-36b590: updating failed example 2. * Adding examples to rule presentational-children-no-focusable-content-307n5z * Update _rules/presentational-children-no-focusable-content-307n5z.md * Update _rules/presentational-children-no-focusable-content-307n5z.md Co-authored-by: Carlos Duarte <[email protected]> * Update _rules/presentational-children-no-focusable-content-307n5z.md Co-authored-by: Carlos Duarte <[email protected]> * Update _rules/presentational-children-no-focusable-content-307n5z.md Co-authored-by: Carlos Duarte <[email protected]> * Inapplicable Example 4: - reducing verbosity. - removing most commentary on "hidden" vs. "presentational". - removing all commentary on "marked as decorative". * Updating Inapplicable Example 4 and references to rule 6cfa84. * Updating Inapplicable Example 1 because of #2099 (comment) * updating Inapplicable Example 2 based on #2099 (comment) * removing Inapplicable Example 3 and replacing it w/ wording in the "background" section. in response to #2099 (comment) * updating Background in response to #2099 (comment) * Updating "Inapplicable Example 1" as per https://github.com/act-rules/act-rules.github.io/pull/2099/files#r1426483648 * Inapplicable Example 1: fixing whitespace. * Update _rules/presentational-children-no-focusable-content-307n5z.md Co-authored-by: Jean-Yves Moyen <[email protected]> * Update _rules/presentational-children-no-focusable-content-307n5z.md Co-authored-by: Jean-Yves Moyen <[email protected]> * Update _rules/presentational-children-no-focusable-content-307n5z.md Co-authored-by: Jean-Yves Moyen <[email protected]> * Update _rules/presentational-children-no-focusable-content-307n5z.md Co-authored-by: Jean-Yves Moyen <[email protected]> * Update _rules/presentational-children-no-focusable-content-307n5z.md Co-authored-by: Jean-Yves Moyen <[email protected]> * Update _rules/presentational-children-no-focusable-content-307n5z.md Co-authored-by: Jean-Yves Moyen <[email protected]> --------- Co-authored-by: Jean-Yves Moyen <[email protected]> Co-authored-by: Carlos Duarte <[email protected]>
1 parent 994ccc0 commit 32fe6af

File tree

1 file changed

+57
-8
lines changed

1 file changed

+57
-8
lines changed

_rules/presentational-children-no-focusable-content-307n5z.md

Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,17 @@ This rule assumes that elements that are part of [sequential focus navigation][]
4343

4444
Several major browsers ignore the WAI-ARIA requirements on [presentational children][] for most or sometimes all roles, or in presence of focusable content. Since some browsers implement presentational children while others do not, pages failing this rule may only be problematic with some browsers.
4545

46+
This rule is often misunderstood as applying to elements with an _explicit_ role of `presentation`. In fact, this rule only applies to elements which have been given an _implicit_ role of `presentation` through the [presentational children][] mechanism. Similarly, this rule does not apply to elements with `aria-hidden="true"`.
47+
4648
### Related rules
4749

48-
- [Element with aria-hidden has no focusable content](https://www.w3.org/WAI/standards-guidelines/act/rules/6cfa84/)
50+
- [Element with aria-hidden has no content in sequential focus navigation](https://www.w3.org/WAI/standards-guidelines/act/rules/6cfa84/)
4951

5052
### Bibliography
5153

5254
- [Understanding Success Criterion 1.3.1: Info and Relationships](https://www.w3.org/WAI/WCAG22/Understanding/info-and-relationships)
5355
- [Understanding Success Criterion 4.1.2: Name, Role, Value](https://www.w3.org/WAI/WCAG22/Understanding/name-role-value)
5456
- [WAI-ARIA 1.2 Presentational Children][presentational children]
55-
- [Element with aria-hidden has no focusable content](aria-hidden-no-focusable-content-6cfa84.md)
5657

5758
## Test Cases
5859

@@ -68,7 +69,7 @@ None of these `button` elements has [descendants][] that are included in [sequen
6869

6970
#### Passed Example 2
7071

71-
This element with `checkbox` role has no [descendants][] that are included in [sequential focus navigation][]. Instead the link to the terms of service is adjacent, and `aria-labelledby` is used to provide its [accessible name][].
72+
This element with the `checkbox` role has no [descendants][] that are included in [sequential focus navigation][]. Instead the link to the terms of service is adjacent, and `aria-labelledby` is used to provide its [accessible name][].
7273

7374
```html
7475
<p id="terms">
@@ -81,7 +82,7 @@ This element with `checkbox` role has no [descendants][] that are included in [s
8182

8283
#### Passed Example 3
8384

84-
This element with `menuitemcheckbox` role has an `input` element as a descendant. Because the `input` is disabled it is not included in [sequential focus navigation][].
85+
This element with the `menuitemcheckbox` role has an `input` element as a descendant. Because the `input` is disabled it is not included in [sequential focus navigation][].
8586

8687
**Note**: The `input` checkbox has a `role` [attribute value][] of `none` to ensure it is ignored by browsers that do not support [presentational children][].
8788

@@ -94,6 +95,15 @@ This element with `menuitemcheckbox` role has an `input` element as a descendant
9495
</ul>
9596
```
9697

98+
#### Passed Example 4
99+
100+
This `<button>` element has an `a` element as a [child][]. The `a` element has no `href` attribute, so it isn't included in [sequential focus navigation][]. So this `button` element passes the rule.
101+
102+
```html
103+
<button><a>button/link</a></button>
104+
```
105+
106+
97107
### Failed
98108

99109
#### Failed Example 1
@@ -109,15 +119,15 @@ This `button` element has a [child][] `span` element. Because the `span` element
109119

110120
#### Failed Example 2
111121

112-
This element with `checkbox` role has an `a` element as a [child][]. Because the `a` element has an `href` attribute, it is included in [sequential focus navigation][].
122+
This element with the `checkbox` role has an `a` element as a [child][]. Because the `a` element has an `href` attribute, it is included in [sequential focus navigation][].
113123

114124
```html
115125
<p role="checkbox" aria-checked="false" tabindex="0">I agree to the <a href="/terms">terms of service</a></p>
116126
```
117127

118128
#### Failed Example 3
119129

120-
This element with `menuitemcheckbox` role has a checkbox as a child. Because the checkbox is not disabled, it is included in [sequential focus navigation][].
130+
This element with the `menuitemcheckbox` role has a checkbox as a child. Because the checkbox is not disabled, it is included in [sequential focus navigation][].
121131

122132
```html
123133
<ul role="menu">
@@ -128,14 +138,53 @@ This element with `menuitemcheckbox` role has a checkbox as a child. Because the
128138
</ul>
129139
```
130140

141+
#### Failed Example 4
142+
143+
This element with the `tab` role contains an `a` element. The `tab` role has [presentational children][]. The `a` element is included in [sequential focus navigation][]. So the element with the `tab` role fails the rule. (This tablist implementation is non-functional for users. It's not meant to function - it's only meant to show roles.)
144+
145+
```html
146+
<ul role="tablist">
147+
<li role="tab">
148+
<a href="#">Tab 1</a>
149+
</li>
150+
</ul>
151+
```
152+
153+
#### Failed Example 5
154+
155+
This element with the `img` role contains an `a` element. The `img` role has [presentational children][]. The `a` element is included in [sequential focus navigation][]. So the element with the `img` role fails the rule.
156+
157+
```html
158+
<span role="img" aria-label="some ASCII art">****** This ASCII art ******* <a href="#">contains a link.</a></span>
159+
```
160+
131161
### Inapplicable
132162

133163
#### Inapplicable Example 1
134164

135-
This element has a `link` role which does not have [presentational children][].
165+
None of the roles that build this semantic table structure (`table` for `table`, `row` for `tr`, `columnheader` for `th`, and `cell` for `td`) have [presentational children][]. So this rule does not apply to them.
166+
167+
```html
168+
<table>
169+
<thead>
170+
<tr>
171+
<th><a href="#">link in table header cell - no problem</a></th>
172+
</tr>
173+
</thead>
174+
<tbody>
175+
<tr>
176+
<td><a href="#">link in table data cell - no problem</a></td>
177+
</tr>
178+
</tbody>
179+
</table>
180+
```
181+
182+
#### Inapplicable Example 2
183+
184+
This `a` element has a `link` role, which does not have [presentational children][]. So this `a` element does not fail this rule, because it's inapplicable. To have a "focusable element within a focusable element" like this is a bad practice, but this rule doesn't directly check for it.
136185

137186
```html
138-
<a href="https://w3.org">W3C Website</a>
187+
<a href="https://w3.org"><span tabindex="0">W3C Website</span></a>
139188
```
140189

141190
[accessible name]: #accessible-name 'Definition of Accessible name'

0 commit comments

Comments
 (0)