Skip to content

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

Open tickets
TicketRequested byPriorityActions
Printer on floor 3 jamsDana RuizHigh
Badge reader at the loading dockKofi MensahMedium
Cannot join the weekly video callInes ArvidssonLow
Monitor flickers at desk 14Ravi PatelMedium

Each ticket's title is a link, and Assign and Close ticket are buttons. Tab through one row and press Enter. Clicking elsewhere in the row opens the ticket too, as a shortcut, but never the only way. Close ticket removes the row and offers Undo.

Do: Hidden actions show on focus

Open tickets
TicketRequested byPriorityActions
Printer on floor 3 jamsDana RuizHigh
Badge reader at the loading dockKofi MensahMedium
Cannot join the weekly video callInes ArvidssonLow
Monitor flickers at desk 14Ravi PatelMedium

The buttons stay out of sight until the pointer is over a row. Press Tab to the first ticket link: the whole row's actions appear, and the next Tab lands on one you can see. They are always shown where there is no hover, as on a phone.

Don't: Only a click on the row opens the ticket

Open tickets
TicketRequested byPriorityActions
Printer on floor 3 jamsDana RuizHigh
Badge reader at the loading dockKofi MensahMedium
Cannot join the weekly video callInes ArvidssonLow
Monitor flickers at desk 14Ravi PatelMedium

Click a row and its ticket opens. Press Tab: focus reaches the buttons but no ticket, and no key opens one. The row acts as a link but has no link in it.

Don't: Actions that show only on hover

Open tickets
TicketRequested byPriorityActions
Printer on floor 3 jamsDana RuizHigh
Badge reader at the loading dockKofi MensahMedium
Cannot join the weekly video callInes ArvidssonLow
Monitor flickers at desk 14Ravi PatelMedium

Move the pointer over a row: Assign and Close ticket appear. Press Tab from the link instead: focus moves onto buttons that cannot be seen, and Enter on one closes a ticket the person never saw a control for.

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 Next Link) 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 the TableRow has the class group. A button inside a cell that is itself at opacity-0 stays invisible whatever its own classes say. Our own advice, which goes further: add group-focus-within:opacity-100 to 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 DropdownMenu on 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 TableRow an onClick that opens the ticket and cursor-pointer, with no link in the row.
  • Put role="link" on the tr. The row stops being a row, and its name becomes the text of every cell.
  • Put tabIndex={0} on the tr and 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-100 and nothing for focus, so a keyboard user tabs onto Close ticket without seeing it.
  • Render the buttons only while onMouseEnter has 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

Stances on TBL-003
SourceRoleStancePage
WCAG 2.2LawRequires2.1.1 Keyboard
WCAG 2.2LawRequires4.1.2 Name, Role, Value
WCAG 2.2LawRequires2.4.7 Focus Visible
WCAG 2.2LawSupports1.4.13 Content on Hover or Focus
Material DesignJudge No position
Apple Human Interface GuidelinesJudge No position
Carbon Design SystemJudge SupportsData table: usage
Data table: accessibility
GOV.UK Design SystemExpert witness No position
Nielsen Norman GroupExpert witness SupportsData 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