Repository navigation
Reach, open and move between clickable Table rows from the keyboard and screen readers - #244
Conversation
A TableRow with clickable and onClick now takes focus as a single tab stop per TableBody, opens on Enter, and moves with Up, Down, Home and End. Keys on controls inside the row stay with those controls, and clicks inside a portal opened from the row no longer trigger it. Fixes GRD-565 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e-reach-open-and-move-between-clickable # Conflicts: # packages/demo/src/content/docs/components/table.mdx # packages/ui/CHANGELOG.md
tmccoy14
left a comment
There was a problem hiding this comment.
Nice work on this. The roving tab stop is done carefully: portal clicks and key presses are filtered with currentTarget.contains, the tab stop falls back to the first row when the active row is removed, and the consumer's onKeyDown, onFocus, tabIndex and refs are all passed through. The tests cover every main case in the ticket. Fixing the bug where a menu item click also triggered the row is a good catch.
I left a few inline comments. Two are about what screen reader users get from a focused row, and one is about the click filter against what the docs now promise. There's also one question from the ticket still open: Cmd/Ctrl-click to open in a new tab. Could we record a decision on that, even if it's "not supported, use href"?
Smaller optional items:
focusableRowsincludes rows hidden withdisplay:noneorhidden.focus()does nothing on them, so ArrowDown can get stuck before a hidden row, and a hidden row can become the active row, which makes Tab skip the table.- A consumer passing
tabIndex={-1}still getsdata-table-row-focusable, so that row can become the active row and Tab skips the table. - Holding Enter repeats
click(). Anif (e.repeat) return;would stop repeatednavigatecalls or selection flipping back and forth. - Each row first renders with
tabIndex=-1and renders again once its ref callback sets state. It's harmless because the layout effect fixes it before paint, but it's one extra render per row. - Rows outside a
TableBodyall gettabIndex=0. That's a reasonable fallback, but a test or a docs line would make it intentional. - Docs: "a single stop" is really one stop per
TableBody. The Usage example usesAgentActionsMenu, which is a Guardian name, and an inlineDropdownMenuwould be clearer. - Since this replaces the hand-rolled "make the name cell a link" workaround, consider adding a row to the name translation table in
packages/skills/equality-design-system/SKILL.md, as CLAUDE.md asks. - Tests could also cover modifier keys being ignored, and a consumer
onKeyDownthat callspreventDefault()stopping the row's handling.
Generated by Claude Code
VoiceOver never announces a focused table row as something that opens, and can't reach a link placed directly in a <tr> in Safari. TableRowAction wraps the row's name in a link (with href) or button (with onClick only), stretched over the row, so it is announced in place without an extra label and becomes the row's keyboard stop. A row with href and onClick now runs onClick on a plain click and leaves modified clicks to the browser, so routers open rows without a reload and Cmd/Ctrl-click opens a new tab. Clicks on form controls inside a row no longer open it. Selection uses a checkbox only, and a selected row highlights whether or not it is clickable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This took a while! Tested with voiceover (both myself and Claude) and had to add an extra prop to make this work. Our tables should now offer much better keyboard navigation and improved auditory cues for non-visual users. Going to skip most of the optional suggestions here unless you object? Seems like overbuilding. |
tmccoy14
left a comment
There was a problem hiding this comment.
Thanks for the thorough VoiceOver testing. The comparison table in the description makes the case for TableRowAction clearly.
All four earlier threads are addressed: a focused row is now announced as a link or button, the click filter covers form controls and menu items (with tests), modified clicks are left to the browser when the row has href with onClick, and selection goes through a labelled Checkbox. The docs fixes look good too. I'm fine skipping the remaining optional items.
One optional nit: the CSS that lifts controls above the row overlay (table-components.module.css:139-146) is shorter than ROW_CONTROLS in the TSX. It leaves out [role=menuitem] and [contenteditable], so a contenteditable in a linked row would sit under the overlay and open the row when clicked. Making the two lists match would close that.
Before merging: the branch now conflicts with main in packages/ui/CHANGELOG.md after 6.2.0, so CI hasn't run on the last two commits. Locally on c146bd1, lint, format check, typecheck, build and all 315 UI tests pass.
Also worth noting: the AGENTS.md change narrows when the translation table gets a row, which applies to the whole repo and not just this component.
Generated by Claude Code
…e-reach-open-and-move-between-clickable
matthewmr-eqty
left a comment
There was a problem hiding this comment.
Great work on this. I had Claude run it locally against 7.0.0 with the keyboard: rows open and move as described, and row heights, the cell pull and focus rings are unchanged. Approving. I'll fold the changelog into 7.1.0 when #256 goes in.
|
Checked, Looks like it's good to merge from me! |
Need: teams waiting on keyboard-reachable table rows should see them in the 7.1.0 notes. Problem: #244 landed under Unreleased, apart from the release it ships in. Solution: its entries join the matching 7.1.0 lists after the release's own, and the Unreleased heading is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Need: product pages need a page title that leads without shouting, and dialogs need a title of their own. Problem: text-title was 30, and Dialog, Sheet and AlertDialog each set their own 18 title off the text styles. Solution: five text styles on the size steps, title-2 for dialogs, cn exported on tailwind-merge 3, and #244's keyboard-reachable table rows
Fixes GRD-565. Goes along with eqtylab/guardian#836.
What changed
TableRowAction(new) wraps the text that names a row in its cell. It becomes the row's link when the row has anhref, or a button when it has onlyonClick, and it's stretched over the row, so the row stays one click target.TableBodyis one Tab stop. Enter opens the row, and Up, Down, Home and End move between rows. The stop is the row'sTableRowAction, else its link, else (aclickablerow with onlyonClick) the row itself.hrefandonClick, a plain click runsonClickinstead of following the link, sonavigateopens the row without a reload. Cmd, Ctrl, Shift and middle clicks open the URL in a new tab or window.Checkboxonly, labelled by the name cell.data-state="selected"now highlights any body row, not only aclickableone.clickableis only needed for anonClickrow without aTableRowAction.Why
TableRowActionI tested the options with VoiceOver in Safari and Chrome:
<tr><tr>+aria-describedbyhinthreflink (a direct child of the<tr>)hrefLabelrepeats the row's name.onClickwith no reload.Wrapping the name gives the row a role screen readers announce without adding a label. The link also appears in the screen reader's links list and opens with Enter in NVDA and JAWS browse mode; those two are standard link behaviour but weren't tested here.
Worth checking on upgrade
hrefandonClickno longer follows the link on a plain click. Guardian'sfollowLinkInApphelper becomes unnecessary but stays harmless.hrefshould be the URL the browser opens, including the router's basename (React Router'suseHref). Guardian's row hrefs are router paths, so a Cmd-click under a base path would open the wrong URL.hrefand noTableRowActionare now one tab stop per body instead of one per row.🤖 Generated with Claude Code