Skip to content

Commit d9743bf

Browse files
jessebeachbeefancohen
authored andcommitted
Added a paragraph to onclick-has-role.md to explain use of role presentation (#129)
1 parent 318ba68 commit d9743bf

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

docs/rules/onclick-has-role.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Enforce visible, non-interactive elements with click handlers use role attribute. Visible means that it is not hidden from a screen reader. Examples of non-interactive elements are `div`, `section`, and `a` elements without a href prop. The purpose of the role attribute is to identify to screenreaders the exact function of an element. This rule will only test low-level DOM components, as we can not deterministically map wrapper JSX components to their correct DOM element.
44

5+
In cases where a non-interactive element has a handler, but does not map to an interactive role such as `button` or `link` -- for example a `div` container that catches bubbled click events -- `onclick-has-role` may be satisfied by providing a role value of `presentation`. This indicates that the element has no semantic value. A role like `button` or `link` should only be applied when the non-interactive element truly represents such a UI element.
6+
57
#### References
68
1. [MDN](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_button_role#Keyboard_and_focus)
79

@@ -12,6 +14,7 @@ This rule takes no arguments.
1214
### Succeed
1315
```jsx
1416
<div onClick={() => void 0} role="button" />
17+
<div onClick={() => void 0} role="presentation" />
1518
<input type="text" onClick={() => void 0} /> // Interactive element does not require role.
1619
<a tabIndex="0" onClick={() => void 0} /> // tabIndex makes this interactive.
1720
<button onClick={() => void 0} className="foo" /> // button is interactive.

0 commit comments

Comments
 (0)