Skip to content

Commit 4527dda

Browse files
committed
update test and docs
1 parent 16cc986 commit 4527dda

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

docs/rules/accessibility/no-aria-hidden-on-focusable-counter.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
## Rule Details
44

5-
Elements that are focusable should not have `aria-hidden="true"` set.
5+
Elements that are focusable should never have `aria-hidden="true"` set.
66

7-
`aria-hidden="true"` hides an element from assistive technologies, but if the element is still reachable by keyboard, it can cause confusion amongst assistie technology users who may be able to reach the element, but not have access to the element or it's information.
7+
`aria-hidden="true"` hides elements from assistive technologies. `aria-hidden="true"` should only be used to hide non-interactive content such as decorative elements or redundant text. If a focusable element has `aria-hidden="true"`, it can cause confusion amongst assistive technology users who may be able to reach the element but not receive information about it.
88

99
### Resources
1010

1111
- [Accessibility insights: aria-hidden-focus](https://accessibilityinsights.io/info-examples/web/aria-hidden-focus/)
12+
- [Deque: aria-hidden elements do not contain focusable elements](https://dequeuniversity.com/rules/axe/html/4.4/aria-hidden-focus)
13+
- [W3: Element with aria-hidden has no content in sequential focus navigation](https://www.w3.org/WAI/standards-guidelines/act/rules/6cfa84/proposed/)
1214

1315
## Examples
1416

test/linters/accessibility/no_aria_hidden_on_focusable_counter_test.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,24 @@ def test_does_not_warn_if_link_has_aria_hidden_false
2121
assert_empty @linter.offenses
2222
end
2323

24-
def test_warns_when_link_has_aria_hidden_true
25-
@file = "<a aria-hidden='true' href='github.com'>GitHub</a>"
24+
def test_does_not_warn_when_link_has_aria_hidden_true_and_is_not_focusable
25+
@file = "<a aria-hidden='true' tabindex='-1' href='github.com'>GitHub</a>"
2626
@linter.run(processed_source)
2727

28+
assert_empty @linter.offenses
29+
end
30+
31+
def test_warns_when_element_has_aria_hidden_true_and_not_tab_focusable
32+
@file = "<div role='button' tabindex='0' a aria-hidden='true'>GitHub</a>"
33+
@linter.run(processed_source)
2834
refute_empty @linter.offenses
2935
end
3036

31-
def test_does_not_warn_when_link_has_aria_hidden_true_and_is_not_focusable
32-
@file = "<a aria-hidden='true' tabindex='-1' href='github.com'>GitHub</a>"
37+
def test_warns_when_link_has_aria_hidden_true
38+
@file = "<a aria-hidden='true' href='github.com'>GitHub</a>"
3339
@linter.run(processed_source)
3440

35-
assert_empty @linter.offenses
41+
refute_empty @linter.offenses
3642
end
3743

3844
def test_warns_when_element_has_aria_hidden_true_and_is_tab_focusable

0 commit comments

Comments
 (0)