TBL-003 Give every row action its own control the keyboard reaches, and show hidden actions on focus
- Level
- Rule
- Verdict
- Requirement
- Area
- Tables
- Status
- proposed, version 1.0.1
Rule
Give every action a table row offers its own control the keyboard reaches, such as a link, a button or a menu item. A click on the row may be a shortcut, never the only way. An action hidden until the pointer hovers the row is visible whenever it has focus.
Examples
Live examples built with Justified's components. Try them with the mouse, the keyboard or a screen reader.
Do: A link and buttons, with the row click as a shortcut
| Ticket | Requested by | Priority | Actions |
|---|---|---|---|
| Printer on floor 3 jams | Dana Ruiz | High | |
| Badge reader at the loading dock | Kofi Mensah | Medium | |
| Cannot join the weekly video call | Ines Arvidsson | Low | |
| Monitor flickers at desk 14 | Ravi Patel | Medium |
Do: Hidden actions show on focus
| Ticket | Requested by | Priority | Actions |
|---|---|---|---|
| Printer on floor 3 jams | Dana Ruiz | High | |
| Badge reader at the loading dock | Kofi Mensah | Medium | |
| Cannot join the weekly video call | Ines Arvidsson | Low | |
| Monitor flickers at desk 14 | Ravi Patel | Medium |
Don't: Only a click on the row opens the ticket
| Ticket | Requested by | Priority | Actions |
|---|---|---|---|
| Printer on floor 3 jams | Dana Ruiz | High | |
| Badge reader at the loading dock | Kofi Mensah | Medium | |
| Cannot join the weekly video call | Ines Arvidsson | Low | |
| Monitor flickers at desk 14 | Ravi Patel | Medium |
Don't: Actions that show only on hover
| Ticket | Requested by | Priority | Actions |
|---|---|---|---|
| Printer on floor 3 jams | Dana Ruiz | High | |
| Badge reader at the loading dock | Kofi Mensah | Medium | |
| Cannot join the weekly video call | Ines Arvidsson | Low | |
| Monitor flickers at desk 14 | Ravi Patel | Medium |
Why
KBD-001 already asks that the keyboard can do everything the pointer can, and that focus can be seen. This rule is that rule applied to table rows, because two patterns there break it so often. The first is a row that opens its record on click and has no link or button: a keyboard user cannot open the record at all. The second is a cell of buttons that appears only on hover: a keyboard user can tab onto the buttons but cannot see them, and does not know what Enter will do.
The law decides both. WCAG 2.2, 2.1.1 Keyboard is not met when an action works only through a pointer event; the Working Group lists pointer-only handlers as a failure (F54). 4.1.2 Name, Role, Value is not met when a scripted element acts as a control without the role of one, and a row that opens its record on click acts as a link; the failure for links emulated with event handlers covers it (F42). Both failures allow a pointer handler when the same function is also offered in a way that meets the criterion, which is why a row click may stay as a shortcut. 2.4.7 Focus Visible is not met when a control has focus while it cannot be seen. 1.4.13 Content on Hover or Focus supports the rule where a hover opens a popover of actions; TXT-002a covers that case. The criteria do not forbid hiding actions from pointer users at rest, and neither does this rule.
Do
- A helpdesk's table Open tickets has the columns Ticket, Requested by, Priority and Actions. The ticket's title in the first cell, such as Printer on floor 3 jams, is a link (
<a href>or NextLink) to the ticket. Assign and Close ticket are buttons in the last cell, which also comes last in the code (LAY-002). - Add a click on the row as a shortcut to the same ticket if you want one. Let the handler ignore clicks that start on a control, for example by returning when
event.target.closest("a, button, input, label")is set, and when the person has selected text. - When the actions show only on hover, show each one when it has focus. With Tailwind, put the hiding classes on each button, not on the cell:
opacity-0 group-hover:opacity-100 focus-visible:opacity-100, where theTableRowhas the classgroup. A button inside a cell that is itself atopacity-0stays invisible whatever its own classes say. Our own advice, which goes further: addgroup-focus-within:opacity-100to the buttons as well, so all the row's actions are on screen while any control in the row has focus, and the person sees what is coming before tabbing onto it. - Our own advice, beyond the rule: keep the actions on show at rest. If you hide them, show them always on screens without hover, for example with
[@media(hover:none)]:opacity-100, since a phone has no hover to reveal them. - With more actions than fit, put them in a
DropdownMenuon each row. Give its icon-only trigger a name as ACT-001b asks. Our own advice: include the row in it, such as "Actions for Printer on floor 3 jams", so the triggers on different rows can be told apart. - A checkbox to select the row stops the click from reaching the row's handler, with
onClick={(e) => e.stopPropagation()}, so ticking it does not open the ticket. Its name is FRM-010's. - Keep every action button at least 24 by 24 CSS pixels in a dense table, as ACT-006 asks.
- When Close ticket removes the row, offer Undo as DST-001a says.
Don't
- Give
TableRowanonClickthat opens the ticket andcursor-pointer, with no link in the row. - Put
role="link"on thetr. The row stops being a row, and its name becomes the text of every cell. - Put
tabIndex={0}on thetrand handle Enter. The row takes focus but has no control role, so a screen reader does not say it can be activated, and 4.1.2 is still not met. - Wrap the whole row in an
a, which is not valid inside a table, or stretch a link over a row that also holds buttons, so it covers them. - Hide the action cell with
opacity-0 group-hover:opacity-100and nothing for focus, so a keyboard user tabs onto Close ticket without seeing it. - Render the buttons only while
onMouseEnterhas set a state, so they are not in the page at all for a keyboard user, unless the actions are offered elsewhere. - Name every row's menu trigger "Open menu".
Exceptions
- Actions offered elsewhere. An action that is also offered on the record's own page, which the row's link reaches, need not be in the row. The row's link must still be there.
- The keyboard in general. Keyboard operation and the focus indicator are KBD-001. This rule adds nothing to it beyond the table case.
- Neighbouring rules. Where a row's buttons sit is ACT-003b, their names ACT-001b, their size ACT-006, the selection checkbox's name FRM-010 and Undo after a removal DST-001a. Tooltips are TXT-002b. The table's structure is TBL-001. That the row's link and buttons have a control role, and the row none, is ACT-009 in general.
Verdict
Requirement. Only the judges decide; the expert witnesses are shown but do not vote. How verdicts work
| Source | Role | Stance | Page |
|---|---|---|---|
| WCAG 2.2 | Law | Requires | 2.1.1 Keyboard |
| WCAG 2.2 | Law | Requires | 4.1.2 Name, Role, Value |
| WCAG 2.2 | Law | Requires | 2.4.7 Focus Visible |
| WCAG 2.2 | Law | Supports | 1.4.13 Content on Hover or Focus |
| Material Design | Judge | No position | |
| Apple Human Interface Guidelines | Judge | No position | |
| Carbon Design System | Judge | Supports | Data table: usage Data table: accessibility |
| GOV.UK Design System | Expert witness | No position | |
| Nielsen Norman Group | Expert witness | Supports | Data Tables: Four Major User Tasks, by Page Laubheimer |
Each stance links to the page it rests on, read on the date in the source register. This page never repeats what a source says; read the source itself.
History
- Version 1.0.1, : Points to ACT-009 for the role of the row's controls.
- Version 1.0.0, : First version.
Last checked against the other rules for conflicts on .
More in Tables: 3 rules and 1 guideline · All rules
Justified is an independent project. It is not affiliated with, sponsored or endorsed by the organisations whose guidance it cites. Read the full statement.
Apple is a trademark of Apple Inc., registered in the U.S. and other countries and regions.