Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Element with presentational children has no focusable content" (rule 307n5z) - adding examples #2099

Open
wants to merge 25 commits into
base: develop
Choose a base branch
from
Open
Changes from 19 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
aeafb90
invalid-form-field-value-36b590: updating failed example 2.
dan-tripp-siteimprove Apr 4, 2023
5a07973
Merge branch 'develop' into develop
Jym77 Apr 27, 2023
a75c7f8
Merge branch 'act-rules:develop' into develop
dan-tripp-siteimprove May 24, 2023
f920a47
Merge branch 'act-rules:develop' into develop
dan-tripp-siteimprove Jun 22, 2023
75a9878
Merge branch 'act-rules:develop' into develop
dan-tripp-siteimprove Aug 17, 2023
81caf8a
Adding examples to rule presentational-children-no-focusable-content-…
dan-tripp-siteimprove Aug 17, 2023
22022c0
Update _rules/presentational-children-no-focusable-content-307n5z.md
dan-tripp-siteimprove Sep 1, 2023
78642d0
Update _rules/presentational-children-no-focusable-content-307n5z.md
dan-tripp-siteimprove Sep 21, 2023
e5f76d7
Update _rules/presentational-children-no-focusable-content-307n5z.md
dan-tripp-siteimprove Sep 21, 2023
552c293
Update _rules/presentational-children-no-focusable-content-307n5z.md
dan-tripp-siteimprove Sep 21, 2023
d161d08
Inapplicable Example 4:
dan-tripp-siteimprove Sep 21, 2023
d7ea3d3
Updating Inapplicable Example 4 and references to rule 6cfa84.
dan-tripp-siteimprove Oct 2, 2023
9dd1ac6
Updating Inapplicable Example 1 because of https://github.com/act-rul…
dan-tripp-siteimprove Dec 1, 2023
527cfd9
updating Inapplicable Example 2 based on https://github.com/act-rules…
dan-tripp-siteimprove Dec 1, 2023
9f81ae4
removing Inapplicable Example 3 and replacing it w/ wording in the "b…
dan-tripp-siteimprove Dec 1, 2023
c8d188d
updating Background in response to https://github.com/act-rules/act-r…
dan-tripp-siteimprove Dec 1, 2023
885d122
Merge branch 'develop' into presentational-children-no-focusable-cont…
carlosapaduarte Feb 13, 2024
79268bb
Updating "Inapplicable Example 1" as per https://github.com/act-rules…
dan-tripp-siteimprove Mar 5, 2024
58d6884
Inapplicable Example 1: fixing whitespace.
dan-tripp-siteimprove Mar 5, 2024
da4739a
Update _rules/presentational-children-no-focusable-content-307n5z.md
dan-tripp-siteimprove Mar 7, 2024
6b0499d
Update _rules/presentational-children-no-focusable-content-307n5z.md
dan-tripp-siteimprove Mar 7, 2024
6fe0e72
Update _rules/presentational-children-no-focusable-content-307n5z.md
dan-tripp-siteimprove Mar 7, 2024
22ea612
Update _rules/presentational-children-no-focusable-content-307n5z.md
dan-tripp-siteimprove Mar 7, 2024
b2c55fe
Update _rules/presentational-children-no-focusable-content-307n5z.md
dan-tripp-siteimprove Mar 7, 2024
58cd998
Update _rules/presentational-children-no-focusable-content-307n5z.md
dan-tripp-siteimprove Mar 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 57 additions & 8 deletions _rules/presentational-children-no-focusable-content-307n5z.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,17 @@ This rule applies to elements with a [semantic role][] that defines its [childre

Elements with a [semantic role][] that has [presentational children][] will not have any descendants in the accessibility tree. If any of those descendants are included in [sequential focus navigation][], this causes the focus to land on an element that has no corresponding node in the [accessibility tree][]. The result is that there is no programmatic name or role available for assistive technologies. There are other problems that can come from [presentational children][] too. These must be tested separately.

This rule is often misunderstood as applying to elements with an <i>explicit</i> role of `presentation`. In fact, this rule only applies to elements which have been given an <i>implicit</i> role of `presentation` through the [presentational children][] mechanism. Similarly, this rule does not apply to elements with `aria-hidden="true"`.
dan-tripp-siteimprove marked this conversation as resolved.
Show resolved Hide resolved

### Related rules

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

### Bibliography

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

## Test Cases

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

#### Passed Example 2

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][].
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][].

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

#### Passed Example 3

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][].
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][].

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

Expand All @@ -93,6 +94,15 @@ This element with `menuitemcheckbox` role has an `input` element as a descendant
</ul>
```

#### Passed Example 4

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.
dan-tripp-siteimprove marked this conversation as resolved.
Show resolved Hide resolved

```html
<button><a>button/link</a></button>
```


### Failed

#### Failed Example 1
Expand All @@ -108,15 +118,15 @@ This `button` element has a [child][] `span` element. Because the `span` element

#### Failed Example 2

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][].
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][].

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

#### Failed Example 3

This element with `menuitemcheckbox` role has a checkbox as a child. Because the checkbox is not disabled, it is included in [sequential focus navigation][].
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][].

```html
<ul role="menu">
Expand All @@ -127,14 +137,53 @@ This element with `menuitemcheckbox` role has a checkbox as a child. Because the
</ul>
```

#### Failed Example 4

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.)
dan-tripp-siteimprove marked this conversation as resolved.
Show resolved Hide resolved

```html
<ul role="tablist">
<li role="tab">
<a href="#">Tab 1</a>
</li>
</ul>
```

#### Failed Example 5

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.
dan-tripp-siteimprove marked this conversation as resolved.
Show resolved Hide resolved

```html
<span role="img" aria-label="some ASCII art">****** This ASCII art ******* <a href="#">contains a link.</a></span>
```

### Inapplicable

#### Inapplicable Example 1

This element has a `link` role which does not have [presentational children][].
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.
dan-tripp-siteimprove marked this conversation as resolved.
Show resolved Hide resolved

```html
<table>
<thead>
<tr>
<th><a href="#">link in table header cell - no problem</a></th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="#">link in table data cell - no problem</a></td>
</tr>
</tbody>
</table>
```

#### Inapplicable Example 2

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.
dan-tripp-siteimprove marked this conversation as resolved.
Show resolved Hide resolved

```html
<a href="https://w3.org">W3C Website</a>
<a href="https://w3.org"><span tabindex="0">W3C Website</span></a>
```

[accessible name]: #accessible-name 'Definition of Accessible name'
Expand Down
Loading