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

6cfa84: Modify pass example 4 to be more realistic, using a dialog #1819

Merged
merged 19 commits into from Jun 16, 2022
Merged
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 40 additions & 3 deletions _rules/aria-hidden-no-focusable-content-6cfa84.md
Expand Up @@ -97,13 +97,28 @@ This `input` element is not [focusable][] because of the `disabled` attribute.

#### Passed Example 4

This `a` element is not [focusable][] because it moves focus to the `input` element whenever it receives focus.
This `a` element is not [focusable][] because it moves focus to the `input` element whenever it receives focus. These elements
are sometimes referred to as 'focus sentinel' or 'bumper'. They are typically found before and after a modal / dialog in
order to contain focus within the modal. Page authors do not want the sentinel to be visible, nor do they want them to be read by
a screen reader. But, they do want the element to be part of the [sequential focus navigation][]. This allows the page author
tombrunet marked this conversation as resolved.
Show resolved Hide resolved
to detect that focus has left the dialog in order to wrap it to the top/bottom as appropriate.

```html
<div id="sampleModal" role="dialog" aria-label="Sample Modal" aria-modal="true" style="border: solid black 1px; padding: 1rem;">
<label>First and last name <input id="dialogFirst"></label><br />
<button id="closeButton">Close button</button>
</div>
<div aria-hidden="true">
<a href="/" style="position:absolute; top:-999em" onfocus="document.querySelector('input').focus()">First link</a>
<a href="#" id="sentinelAfter" style="position:absolute; top:-999em">Upon receiving focus, this focus sentinel should wrap focus to the top of the modal</a>
</div>
<input />
<script>
document.getElementById("sentinelAfter").addEventListener("focus", () => {
document.getElementById("dialogFirst").focus();
});
document.getElementById("closeButton").addEventListener("click", () => {
document.getElementById("sampleModal").style.display = "none";
});
</script>
```

### Failed
Expand Down Expand Up @@ -169,6 +184,27 @@ This `summary` element is [focusable][].
</details>
```

#### Failed Example 7

This `a` element is [focusable][] because it fails to move focus when it receives focus. This is in contrast to a focus sentinel that
immediately jumps focus to a valid location. Focus sentinels are typically used before and after a modal dialog in order to contain
and wrap focus. In this case, the `focus` event was removed, but the sentinel was not.

```html
<div id="sampleModal" role="dialog" aria-label="Sample Modal" aria-modal="true" style="border: solid black 1px; padding: 1rem;">
<label>First and last name <input id="dialogFirst"></label><br />
<button id="closeButton">Close button</button>
</div>
<div aria-hidden="true">
<a href="#" id="sentinelAfter" style="position:absolute; top:-999em">Upon receiving focus, this focus sentinel should wrap focus to the top of the modal</a>
</div>
<script>
document.getElementById("closeButton").addEventListener("click", () => {
document.getElementById("sampleModal").style.display = "none";
});
</script>
```

### Inapplicable

#### Inapplicable Example 1
Expand Down Expand Up @@ -199,3 +235,4 @@ This `aria-hidden` attribute has an incorrect value.

[attribute value]: #attribute-value 'Definition of Attribute Value'
[focusable]: #focusable 'Definition of focusable'
[sequential focus navigation]: https://html.spec.whatwg.org/#sequential-focus-navigation 'HTML sequential focus navigation, 2020/08/12'