feat(ui): reach the row's actions with a keyboard, and stop saying things twice
UI-SPEC §8's remaining keyboard work, and it turned out to be hiding a WCAG 2.1.1 failure.
**Pin and uninstall were unreachable without a mouse.** Every control in a package row is
`tabIndex={-1}` so that 200 rows do not become 600 tab stops — a sound trade for the
checkbox, whose job `Space` already does from the row. Applied to the two action buttons it
removed the actions entirely: the row was the only tab stop, and from it there was nowhere
further to go. Found by tabbing to a row in the running app and pressing every key that
should have done something.
The ARIA grid pattern's answer is a roving tabindex, so that is what this is: `ArrowRight`
and `ArrowLeft` walk the row's controls, `Escape` comes back out to the row, and no tab stops
are added. Verified in the browser — the focus walk is checkbox → *Pin this package* →
*Remove this package* → row.
**`Enter` is the row's primary action, and it is pin rather than uninstall.** A row has one
reversible annotation and one irreversible removal; a destructive operation one keypress away
from a focused row is not a primary action, it is an accident waiting. `Space` still toggles
selection independently — checked, because a new binding on the same element is exactly how
an old one stops working.
Note what the audit actually found: `Enter` already worked everywhere else in the app,
because every other primary action is a real `<button>` and buttons handle it natively. The
gap was one element that only looks like a control.
**Two live regions folded, and the pair that mattered was not the pair the ROADMAP counted.**
`PdEnvDetail` had two on one screen; they are now one, which is safe because a diff cannot be
loading before a snapshot has been selected from the list. And `PdConsoleDrawer` announced
the same `done/total` as the panel that opens it, so a reader heard every step twice — the
drawer's is gone, because the screen owns the announcement and the drawer may be closed while
a run is going. Ten regions down to eight, with the two genuine conflicts removed rather than
the count merely reduced.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6840e0378a
commit
73a67a6243
3 files changed
+50
-13
No files matched your search
@@ -64,8 +64,11 @@ export function PdConsoleDrawer({ lines, open, onClose, done, total }: PdConsole
|
||||
>
|
||||
<div className="flex shrink-0 items-center justify-between border-b border-border px-3 py-1">
|
||||
<span className="text-data text-text-dim">{t('plan.console')}</span>
|
||||
{/* The live region UI-SPEC §8 asks for. Polite, so it does not interrupt. */}
|
||||
<span aria-live="polite" className="font-mono text-data text-text-dim">
|
||||
{/* **Not a live region.** It was one, and so is the screen that opens this drawer — both
|
||||
announcing the same `done/total`, so a reader heard every step twice. §8 asks for one
|
||||
announcement of execution progress, and the screen owns it because the drawer may be
|
||||
closed while a run is going. Still rendered, still read on demand. */}
|
||||
<span className="font-mono text-data text-text-dim">
|
||||
{total > 0 ? t('plan.progress', { done, total }) : ''}
|
||||
</span>
|
||||
<button
|
||||
|
||||
@@ -62,11 +62,45 @@ function Row({
|
||||
// Only when the row itself has focus. Without the target check, Space on a focused action
|
||||
// button toggles the row's selection *as well as* pressing the button — and the pin
|
||||
// button was a tab stop, so that was reachable rather than theoretical.
|
||||
if (e.key === ' ' && !pinned && e.target === e.currentTarget) {
|
||||
const onRow = e.target === e.currentTarget
|
||||
if (e.key === ' ' && !pinned && onRow) {
|
||||
// Otherwise the scroll container pages down under the focused row.
|
||||
e.preventDefault()
|
||||
onToggle(row.name)
|
||||
}
|
||||
// UI-SPEC §8's `Enter` primary action. Pin, not uninstall: a row's two actions are one
|
||||
// reversible annotation and one irreversible removal, and a destructive operation one
|
||||
// keypress from a focused row is not a primary action, it is an accident waiting.
|
||||
if (e.key === 'Enter' && onRow) {
|
||||
e.preventDefault()
|
||||
onPinToggle(row.name)
|
||||
}
|
||||
// **The ARIA grid pattern's roving tabindex, and the reason it is here at all.** Every
|
||||
// control in this row is `tabIndex={-1}` so that 200 rows do not become 600 tab stops —
|
||||
// but that left *pin* and *uninstall* reachable by mouse only, which is a WCAG 2.1.1
|
||||
// failure and breaks §8's "full keyboard traversal". Found by tabbing to a row in the
|
||||
// running app and discovering there was nowhere further to go. Arrow keys move within the
|
||||
// row; `Escape` comes back out to it.
|
||||
if (e.key === 'ArrowRight' || e.key === 'ArrowLeft') {
|
||||
const controls = [
|
||||
...e.currentTarget.querySelectorAll<HTMLElement>('button, input'),
|
||||
].filter((el) => !(el as HTMLButtonElement).disabled)
|
||||
if (controls.length === 0) return
|
||||
e.preventDefault()
|
||||
const at = controls.indexOf(document.activeElement as HTMLElement)
|
||||
const step = e.key === 'ArrowRight' ? 1 : -1
|
||||
// From the row itself, ArrowRight enters at the first control and ArrowLeft at the last.
|
||||
const next = at === -1 ? (step === 1 ? 0 : controls.length - 1) : at + step
|
||||
if (next < 0 || next >= controls.length) {
|
||||
e.currentTarget.focus()
|
||||
return
|
||||
}
|
||||
controls[next]?.focus()
|
||||
}
|
||||
if (e.key === 'Escape' && !onRow) {
|
||||
e.preventDefault()
|
||||
e.currentTarget.focus()
|
||||
}
|
||||
}}
|
||||
style={style}
|
||||
className={`absolute top-0 left-0 flex w-full items-center gap-3 border-b border-border px-3 ${
|
||||
|
||||
@@ -84,11 +84,15 @@ export function PdEnvDetail() {
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{snapshotsLoading === 'loading' ? (
|
||||
<p aria-live="polite" className="mt-4 text-data text-text-dim">
|
||||
{t('snapshots.loading')}
|
||||
</p>
|
||||
) : null}
|
||||
{/* **One live region for the screen**, not one per loading state. Two polite regions on the
|
||||
same screen serialize in an order neither of them controls, so a reader can hear the
|
||||
older message after the newer one. This one covers both waits; the snapshot list and a
|
||||
diff are never loading at the same moment, because a diff needs a selection from the
|
||||
list. */}
|
||||
<p aria-live="polite" className="mt-4 text-data text-text-dim">
|
||||
{snapshotsLoading === 'loading' ? t('snapshots.loading') : null}
|
||||
{diffLoading === 'loading' ? t('snapshots.diffing') : null}
|
||||
</p>
|
||||
|
||||
{snapshotsLoading === 'ready' && snapshots.length === 0 ? (
|
||||
<PdEmptyState message={t('snapshots.empty')} hint={t('snapshots.emptyHint')} />
|
||||
@@ -105,11 +109,7 @@ export function PdEnvDetail() {
|
||||
|
||||
{selectedSnapshot !== null && usable ? (
|
||||
<div className="mt-6 border-t border-border pt-4">
|
||||
{diffLoading === 'loading' ? (
|
||||
<p aria-live="polite" className="text-data text-text-dim">
|
||||
{t('snapshots.diffing')}
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
|
||||
{diff !== null ? (
|
||||
<>
|
||||
|
||||
Reference in new issue
Block a user