-
Notifications
You must be signed in to change notification settings - Fork 79
new rule: Element with presentational children has no focusable content #1493
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a023c87
new rule: Element with presentational children has no focusable content
WilcoFiers 49da28f
Update presentational-children-no-focusable-content-307n5z.md
WilcoFiers 79b858a
Apply suggestions from code review
WilcoFiers f7034cf
Update presentational-children-no-focusable-content-307n5z.md
WilcoFiers c9c5e56
Apply suggestions from code review
WilcoFiers e28a1de
Update _rules/presentational-children-no-focusable-content-307n5z.md
WilcoFiers ae36bd4
Apply suggestions from code review
WilcoFiers 5012d12
Merge branch 'develop' into presentational-children-not-focusable
WilcoFiers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
144 changes: 144 additions & 0 deletions
144
_rules/presentational-children-no-focusable-content-307n5z.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| --- | ||
| id: 307n5z | ||
| name: Element with presentational children has no focusable content | ||
| rule_type: atomic | ||
| description: | | ||
| This rule checks that elements with a role that makes its children presentational do not contain focusable elements. | ||
| accessibility_requirements: | ||
| wcag20:1.3.1: # Info and Relationships (A) | ||
| forConformance: true | ||
| failed: not satisfied | ||
| passed: further testing needed | ||
| inapplicable: further testing needed | ||
| wcag20:4.1.2: # Name, Role, Value (A) | ||
| forConformance: true | ||
| failed: not satisfied | ||
| passed: further testing needed | ||
| inapplicable: further testing needed | ||
| input_aspects: | ||
| - DOM Tree | ||
| - CSS Styling | ||
| acknowledgments: | ||
| authors: | ||
| - Wilco Fiers | ||
| --- | ||
|
|
||
| ## Applicability | ||
|
|
||
| This rule applies to any HTML or SVG element with a [semantic role][] that defines its [children][child] to be [presentational children][]. | ||
|
|
||
| ## Expectation | ||
|
|
||
| None of the target elements have [descendants][] in the [flat tree][] that are part of [sequential focus navigation][]. | ||
|
|
||
| ## Assumptions | ||
|
|
||
| This rule assumes that elements that are part of [sequential focus navigation][] do not immediately blur, or move focus to another element. Such elements will fail this rule, but may still satisfy success criteria 1.3.1 and 4.1.2. | ||
ajanec01 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ## Accessibility Support | ||
|
|
||
| Several major browsers ignore the WAI-ARIA requirements on [presentational children][] for most or sometimes all roles. Because some browsers do, and others do not implement presentational children, there can be significant differences between browsers. | ||
|
|
||
| ## Background | ||
|
|
||
| This rule applies to elements with a [semantic role][] that defines its [children][child] to be [presentational children][]. This includes the following: `button`, `checkbox`, `img`, `math`, `menuitemcheckbox`, `menuitemradio`, `option`, `progressbar`, `radio`, `scrollbar`, `separator`, `slider`, `switch`, and `tab`. | ||
|
|
||
| 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. | ||
|
|
||
Jym77 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - [Understanding Success Criterion 1.3.1: Info and Relationships](https://www.w3.org/WAI/WCAG21/Understanding/info-and-relationships) | ||
| - [Understanding Success Criterion 4.1.2: Name, Role, Value](https://www.w3.org/WAI/WCAG21/Understanding/name-role-value) | ||
| - [WAI-ARIA 1.1 Presentational Children][presentational children] | ||
|
|
||
| ## Test Cases | ||
|
|
||
| ### Passed | ||
|
|
||
| #### Passed Example 1 | ||
|
|
||
| None of these `button` elements has [descendants][] that are included in [sequential focus navigation][]. | ||
|
|
||
| ```html | ||
| <button>Save</button> <button aria-label="save options" aria-expanded="false">▼</button> | ||
| ``` | ||
|
|
||
| #### 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][]. | ||
|
|
||
| ```html | ||
| <p id="terms"> | ||
| <span role="checkbox" aria-checked="false" tabindex="0" aria-labelledby="terms"> | ||
| I agree to the | ||
| </span> | ||
| <a href="/terms">terms of service</a> | ||
| </p> | ||
| ``` | ||
|
|
||
| #### 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][]. | ||
|
|
||
| **Note**: The `input` checkbox has a `role` [attribute value][] of `none` to ensure it is ignored by browsers that do not support [presentational children][]. | ||
|
|
||
| ```html | ||
| <ul role="menu"> | ||
| <li role="menuitemcheckbox" aria-checked="true"> | ||
| <input type="checkbox" role="none" disabled checked /> | ||
| Sort by Last Modified | ||
| </li> | ||
| </ul> | ||
| ``` | ||
|
|
||
| ### Failed | ||
|
|
||
| #### Failed Example 1 | ||
|
|
||
| This `button` element has a [child][] `span` element. Because the `span` element has a `tabindex` attribute with value of `0`, it is included in [sequential focus navigation][]. | ||
|
|
||
| ```html | ||
| <button> | ||
| Save | ||
| <span aria-label="save options" aria-expanded="false" tabindex="0">▼</span> | ||
| </button> | ||
| ``` | ||
|
|
||
| #### 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][]. | ||
|
|
||
| ```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][]. | ||
|
|
||
| ```html | ||
| <ul role="menu"> | ||
| <li role="menuitemcheckbox" aria-checked="true"> | ||
| <input type="checkbox" checked /> | ||
| Sort by Last Modified | ||
| </li> | ||
| </ul> | ||
| ``` | ||
|
|
||
| ### Inapplicable | ||
|
|
||
| #### Inapplicable Example 1 | ||
|
|
||
| This element has a `link` role which does not have [presentational children][]. | ||
|
|
||
| ```html | ||
| <a href="https://w3.org">W3C Website</a> | ||
| ``` | ||
|
|
||
| [accessible name]: #accessible-name 'Definition of Accessible name' | ||
| [attribute value]: #attribute-value 'Definition of Attribute value' | ||
| [semantic role]: #semantic-role 'Definition of Semantic role' | ||
| [accessibility tree]: https://www.w3.org/TR/accname-1.1/#dfn-accessibility-tree 'Definition of Accessibility tree' | ||
| [presentational children]: https://www.w3.org/TR/wai-aria-1.1/#childrenArePresentational 'WAI-ARIA 1.1 Presentational Children' | ||
| [child]: https://dom.spec.whatwg.org/#concept-tree-child 'Definition child, as on 2020-10-21' | ||
| [descendants]: https://dom.spec.whatwg.org/#concept-tree-descendant 'Definition Descendant, as on 2020-10-21' | ||
| [sequential focus navigation]: https://html.spec.whatwg.org/#sequential-focus-navigation 'HTML sequential focus navigation, 2020/10/21' | ||
| [flat tree]: https://drafts.csswg.org/css-scoping/#flat-tree 'CSS Scoping definition of Flat tree, working draft' | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.