Skip to content

Commit 68931f3

Browse files
committed
Add a case for interaction handlers on table cells to no-noninteractive-element-interactions
1 parent 6be5eab commit 68931f3

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

docs/rules/no-noninteractive-element-interactions.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,40 @@ Headers often double as expand/collapse controls for the content they headline.
5555
</ul>
5656
```
5757

58+
### Case: This element is a table cell
59+
60+
Table cells (and tables in general) are meant to contain data. ARIA provides us with a construct called a [Grid](http://w3c.github.io/aria-practices/#grid) that is essentially a 2 dimensional logical container for content and interactive elements.
61+
62+
You have two options in this case.
63+
64+
#### Option 1, move the interactive content inside the table cells
65+
66+
For instance, move the button inside the cell:
67+
68+
```
69+
<table>
70+
<tr>
71+
<td><button>Sort</button></td>
72+
</tr>
73+
</table>
74+
```
75+
76+
This preserves the table cell semantics and the button semantics; the two are not conflated on the cell.
77+
78+
#### Option 2, convert the table into an ARIA grid
79+
80+
If you're user interface has a table-like layout, but is filled with interactive components in the cells, consider converting the table into a grid.
81+
82+
```
83+
<table role="grid">
84+
<tr>
85+
<td role="gridcell" onClick={this.sort}>Sort</td>
86+
</tr>
87+
</table>
88+
```
89+
90+
You can also put the interactive content inside the grid cell. This maintains the semantic distinction between the cell and the interaction content, although a grid cell can be interactive.
91+
5892
### References
5993

6094
1. [WAI-ARIA roles](https://www.w3.org/TR/wai-aria-1.1/#usage_intro)

0 commit comments

Comments
 (0)