feat: keyboard and screen-reader basics for dialogs, toolbar, and tree

Dialogs move focus in on open, trap Tab, close on Escape, and return focus.
Toolbar icon buttons get aria-labels; away/whisper carets expose their menu
state. Channel and client rows are focusable: Enter joins/opens chat, Space
selects, arrows collapse/expand, the context-menu key opens the menu with
focus on its first item.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
MoepchiandClaude Opus 5.5 committed 2026-10-03 01:50:29 +00:00
1 parent bf4507ae9d
commit 81107c659e
3 files changed
+105 -31

No files matched your search

+8 -13
View File
@@ -47,21 +47,16 @@ This roadmap is intentionally outcome-focused. It does not promise fixed dates.
### Accessibility ### Accessibility
The interface currently assumes a mouse and sighted use; a real pass is Basics are in place: the UI language sets the document's `lang`/`dir`,
still needed: dialogs take focus on open, keep Tab inside, close on Escape, and hand focus
back; toolbar icon buttons are labelled; channel and client rows are
focusable (Enter joins a channel or opens a private chat, Space selects,
the context-menu key or Shift+F10 opens the menu with focus in it). Still to do:
- Replace clickable `<div>`s that aren't real `<button>`s with actual - Replace the remaining clickable `<div>`s with real buttons
buttons, so they're reachable and operable by keyboard - Arrow-key navigation through the tree and menus
- Add keyboard handlers next to the many click-only interactions (channel
tree, context menus, client list)
- Label icon-only toggle controls (mute, away, streaming, recording, ...)
with `aria-label`/`aria-pressed` so their state is announced, not just shown
as a color/icon change
- Fix the document's `lang` attribute to follow the active UI language
instead of staying fixed
- Manage focus in modals and dialogs: move it in on open, return it on close
- Do a full screen-reader pass (NVDA/VoiceOver) through a real connect - Do a full screen-reader pass (NVDA/VoiceOver) through a real connect
session to find what else is missing beyond the above session to find what else is missing
### Deployment experience ### Deployment experience
+5
View File
@@ -2016,6 +2016,11 @@
box-sizing: border-box; box-sizing: border-box;
} }
.ts-app .ts-row:focus-visible {
outline: 2px solid var(--accent);
outline-offset: -2px;
}
.ts-tree-search { .ts-tree-search {
box-sizing: border-box; box-sizing: border-box;
width: 100%; width: 100%;
+92 -18
View File
@@ -2,11 +2,46 @@ import { useEffect, useMemo, useRef, useState, type ReactNode } from "react";
import { useRegisterSW } from "virtual:pwa-register/react"; import { useRegisterSW } from "virtual:pwa-register/react";
import "./App.css"; import "./App.css";
/** Only dismiss on a genuine backdrop click, not a text-selection drag that const FOCUSABLE =
* starts inside the dialog and releases over the backdrop. */ 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
/** Props for a modal dialog's backdrop. Dismisses on Escape or a genuine
* backdrop click (not a text-selection drag that starts inside the dialog
* and releases over the backdrop). Moves focus in on open unless an
* autoFocus field already took it, keeps Tab inside, and hands focus back to
* whatever had it before on close. */
function useBackdropDismiss(onDismiss: () => void) { function useBackdropDismiss(onDismiss: () => void) {
const mouseDownOnBackdrop = useRef(false); const mouseDownOnBackdrop = useRef(false);
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {
const previous = document.activeElement as HTMLElement | null;
const el = ref.current;
if (el && !el.contains(document.activeElement)) el.querySelector<HTMLElement>(FOCUSABLE)?.focus();
return () => previous?.focus?.();
}, []);
return { return {
ref,
role: "dialog",
"aria-modal": true,
onKeyDown: (e: React.KeyboardEvent<HTMLDivElement>) => {
if (e.key === "Escape") {
e.stopPropagation();
onDismiss();
return;
}
if (e.key !== "Tab") return;
const items = [...e.currentTarget.querySelectorAll<HTMLElement>(FOCUSABLE)];
if (items.length === 0) return;
const first = items[0];
const last = items[items.length - 1];
if (e.shiftKey && document.activeElement === first) {
e.preventDefault();
last.focus();
} else if (!e.shiftKey && document.activeElement === last) {
e.preventDefault();
first.focus();
}
},
onMouseDown: (e: React.MouseEvent<HTMLDivElement>) => { onMouseDown: (e: React.MouseEvent<HTMLDivElement>) => {
mouseDownOnBackdrop.current = e.target === e.currentTarget; mouseDownOnBackdrop.current = e.target === e.currentTarget;
}, },
@@ -946,7 +981,7 @@ function ChannelTree({
.filter((g): g is GroupEntry => !!g && g.iconId !== 0) .filter((g): g is GroupEntry => !!g && g.iconId !== 0)
: []; : [];
const toggleCollapsed = (channelId: number, event: React.MouseEvent) => { const toggleCollapsed = (channelId: number, event: React.SyntheticEvent) => {
event.stopPropagation(); event.stopPropagation();
setCollapsed((prev) => { setCollapsed((prev) => {
const next = new Set(prev); const next = new Set(prev);
@@ -996,6 +1031,16 @@ function ChannelTree({
onSwitchChannel(channel.id); onSwitchChannel(channel.id);
}} }}
onContextMenu={(e) => onChannelContextMenu(e, channel.id, channel.name)} onContextMenu={(e) => onChannelContextMenu(e, channel.id, channel.name)}
tabIndex={0}
onKeyDown={(e) => {
if (e.target !== e.currentTarget) return;
if (e.key === "Enter") onSwitchChannel(channel.id);
else if (e.key === " ") onSelectItem({ type: "channel", id: channel.id });
else if (hasChildren && (e.key === "ArrowLeft" || e.key === "ArrowRight") && isCollapsed === (e.key === "ArrowRight"))
toggleCollapsed(channel.id, e);
else return;
e.preventDefault();
}}
onDragOver={(e) => { onDragOver={(e) => {
if (![...e.dataTransfer.types].includes(CLIENT_DRAG_MIME)) return; if (![...e.dataTransfer.types].includes(CLIENT_DRAG_MIME)) return;
e.preventDefault(); e.preventDefault();
@@ -1082,6 +1127,13 @@ function ChannelTree({
c.id === ownClientId ? undefined : () => onOpenPrivateChat(c.id, c.name) c.id === ownClientId ? undefined : () => onOpenPrivateChat(c.id, c.name)
} }
onContextMenu={(e) => onClientContextMenu(e, c.id, c.name, c.id === ownClientId)} onContextMenu={(e) => onClientContextMenu(e, c.id, c.name, c.id === ownClientId)}
tabIndex={0}
onKeyDown={(e) => {
if (e.key === "Enter" && c.id !== ownClientId) onOpenPrivateChat(c.id, c.name);
else if (e.key === " ") onSelectItem({ type: "client", id: c.id });
else return;
e.preventDefault();
}}
title={ title={
c.id === ownClientId c.id === ownClientId
? undefined ? undefined
@@ -8175,9 +8227,14 @@ function AppInner() {
}; };
window.addEventListener("mousedown", onPointerDown); window.addEventListener("mousedown", onPointerDown);
window.addEventListener("keydown", onKeyDown); window.addEventListener("keydown", onKeyDown);
// Keyboard users (context-menu key / Shift+F10) land in the menu and get
// focus back on the row once it closes.
const previous = document.activeElement as HTMLElement | null;
clientContextMenuRef.current?.querySelector<HTMLElement>(FOCUSABLE)?.focus();
return () => { return () => {
window.removeEventListener("mousedown", onPointerDown); window.removeEventListener("mousedown", onPointerDown);
window.removeEventListener("keydown", onKeyDown); window.removeEventListener("keydown", onKeyDown);
if (document.activeElement === document.body) previous?.focus();
}; };
}, [clientContextMenu]); }, [clientContextMenu]);
@@ -8191,9 +8248,14 @@ function AppInner() {
}; };
window.addEventListener("mousedown", onPointerDown); window.addEventListener("mousedown", onPointerDown);
window.addEventListener("keydown", onKeyDown); window.addEventListener("keydown", onKeyDown);
// Keyboard users (context-menu key / Shift+F10) land in the menu and get
// focus back on the row once it closes.
const previous = document.activeElement as HTMLElement | null;
serverContextMenuRef.current?.querySelector<HTMLElement>(FOCUSABLE)?.focus();
return () => { return () => {
window.removeEventListener("mousedown", onPointerDown); window.removeEventListener("mousedown", onPointerDown);
window.removeEventListener("keydown", onKeyDown); window.removeEventListener("keydown", onKeyDown);
if (document.activeElement === document.body) previous?.focus();
}; };
}, [serverContextMenu]); }, [serverContextMenu]);
@@ -8207,9 +8269,14 @@ function AppInner() {
}; };
window.addEventListener("mousedown", onPointerDown); window.addEventListener("mousedown", onPointerDown);
window.addEventListener("keydown", onKeyDown); window.addEventListener("keydown", onKeyDown);
// Keyboard users (context-menu key / Shift+F10) land in the menu and get
// focus back on the row once it closes.
const previous = document.activeElement as HTMLElement | null;
channelContextMenuRef.current?.querySelector<HTMLElement>(FOCUSABLE)?.focus();
return () => { return () => {
window.removeEventListener("mousedown", onPointerDown); window.removeEventListener("mousedown", onPointerDown);
window.removeEventListener("keydown", onKeyDown); window.removeEventListener("keydown", onKeyDown);
if (document.activeElement === document.body) previous?.focus();
}; };
}, [channelContextMenu]); }, [channelContextMenu]);
@@ -9603,6 +9670,10 @@ function AppInner() {
? serverClientsOnline + (showServerQueryClients ? queryClientCount : 0) ? serverClientsOnline + (showServerQueryClients ? queryClientCount : 0)
: treeClients.length; : treeClients.length;
const novaSplash = designTheme === "nova" && !connected; const novaSplash = designTheme === "nova" && !connected;
const micLabel = !micOn ? t("toolbar.micEnable") : inputMuted ? t("toolbar.micUnmute") : t("toolbar.micMute");
const streamLabel = DEMO_MODE
? t("publish.demoUnavailable")
: `${publishState === "live" ? t("publish.stop") : t("publish.start")} (${t("publish.alpha")})`;
return ( return (
<div <div
@@ -10185,6 +10256,7 @@ function AppInner() {
onClick={() => sendAway(!isAway, "")} onClick={() => sendAway(!isAway, "")}
disabled={!connected} disabled={!connected}
title={isAway ? t("toolbar.backOnline") : t("toolbar.setAway")} title={isAway ? t("toolbar.backOnline") : t("toolbar.setAway")}
aria-label={isAway ? t("toolbar.backOnline") : t("toolbar.setAway")}
> >
💤 💤
</button> </button>
@@ -10196,6 +10268,9 @@ function AppInner() {
}} }}
disabled={!connected} disabled={!connected}
title={t("toolbar.awayOptions")} title={t("toolbar.awayOptions")}
aria-label={t("toolbar.awayOptions")}
aria-haspopup="menu"
aria-expanded={awayMenuOpen}
> >
▾ ▾
</button> </button>
@@ -10245,6 +10320,9 @@ function AppInner() {
onClick={() => setWhisperMenuOpen((v) => !v)} onClick={() => setWhisperMenuOpen((v) => !v)}
disabled={!connected} disabled={!connected}
title={t("toolbar.whisper")} title={t("toolbar.whisper")}
aria-label={t("toolbar.whisper")}
aria-haspopup="menu"
aria-expanded={whisperMenuOpen}
> >
🤫 🤫
</button> </button>
@@ -10290,13 +10368,8 @@ function AppInner() {
<button <button
className={`ts-icon-button${micOn && !inputMuted ? " ts-mic-on" : ""}${micOn && inputMuted ? " ts-muted-on" : ""}`} className={`ts-icon-button${micOn && !inputMuted ? " ts-mic-on" : ""}${micOn && inputMuted ? " ts-muted-on" : ""}`}
onClick={handleToggleMic} onClick={handleToggleMic}
title={ title={micLabel}
!micOn aria-label={micLabel}
? t("toolbar.micEnable")
: inputMuted
? t("toolbar.micUnmute")
: t("toolbar.micMute")
}
> >
{micOn && !inputMuted ? "🎤" : "🔇"} {micOn && !inputMuted ? "🎤" : "🔇"}
</button> </button>
@@ -10309,6 +10382,7 @@ function AppInner() {
step={0.002} step={0.002}
value={vadThreshold} value={vadThreshold}
onChange={(e) => setVadThreshold(Number(e.target.value))} onChange={(e) => setVadThreshold(Number(e.target.value))}
aria-label={t("toolbar.vadSensitivity")}
/> />
</label> </label>
<button <button
@@ -10318,11 +10392,8 @@ function AppInner() {
// panel would sit at "starting" forever - after the browser has // panel would sit at "starting" forever - after the browser has
// already asked the visitor to pick a screen. Don't offer it. // already asked the visitor to pick a screen. Don't offer it.
disabled={!connected || ownClientId === null || DEMO_MODE} disabled={!connected || ownClientId === null || DEMO_MODE}
title={ title={streamLabel}
DEMO_MODE aria-label={streamLabel}
? t("publish.demoUnavailable")
: `${publishState === "live" ? t("publish.stop") : t("publish.start")} (${t("publish.alpha")})`
}
> >
{publishState === "live" ? "🛑" : "🖥️"} {publishState === "live" ? "🛑" : "🖥️"}
</button> </button>
@@ -10331,8 +10402,8 @@ function AppInner() {
className={`ts-icon-button${tabAudioOn ? " ts-mic-on" : ""}`} className={`ts-icon-button${tabAudioOn ? " ts-mic-on" : ""}`}
onClick={handleToggleTabAudio} onClick={handleToggleTabAudio}
disabled={!micOn} disabled={!micOn}
aria-pressed={tabAudioOn}
title={tabAudioOn ? t("tabAudio.stop") : t("tabAudio.start")} title={tabAudioOn ? t("tabAudio.stop") : t("tabAudio.start")}
aria-label={tabAudioOn ? t("tabAudio.stop") : t("tabAudio.start")}
> >
🎵 🎵
</button> </button>
@@ -10343,11 +10414,12 @@ function AppInner() {
onClick={handleToggleOutputMuted} onClick={handleToggleOutputMuted}
disabled={!connected} disabled={!connected}
title={outputMuted ? t("toolbar.unmuteSound") : t("toolbar.muteSound")} title={outputMuted ? t("toolbar.unmuteSound") : t("toolbar.muteSound")}
aria-label={outputMuted ? t("toolbar.unmuteSound") : t("toolbar.muteSound")}
> >
{outputMuted ? "🔇" : "🔊"} {outputMuted ? "🔇" : "🔊"}
</button> </button>
{hasNativeOutputPicker() ? ( {hasNativeOutputPicker() ? (
<button className="ts-icon-button" onClick={handlePickOutputDevice} title={t("toolbar.chooseOutputDevice")}> <button className="ts-icon-button" onClick={handlePickOutputDevice} title={t("toolbar.chooseOutputDevice")} aria-label={t("toolbar.chooseOutputDevice")}>
🎧 🎧
</button> </button>
) : ( ) : (
@@ -10357,6 +10429,7 @@ function AppInner() {
value={outputDeviceId} value={outputDeviceId}
onChange={(e) => handleOutputDeviceChange(e.target.value)} onChange={(e) => handleOutputDeviceChange(e.target.value)}
onFocus={refreshOutputDevices} onFocus={refreshOutputDevices}
aria-label={t("toolbar.chooseOutputDevice")}
> >
<option value="">{t("playback.systemDefault")}</option> <option value="">{t("playback.systemDefault")}</option>
{outputDevices.map((d) => ( {outputDevices.map((d) => (
@@ -10368,7 +10441,7 @@ function AppInner() {
</label> </label>
)} )}
{recording && ( {recording && (
<button className="ts-icon-button ts-recording-on" onClick={stopRecording} title={t("menu.extras.stopRecording")}> <button className="ts-icon-button ts-recording-on" onClick={stopRecording} title={t("menu.extras.stopRecording")} aria-label={t("menu.extras.stopRecording")}>
🔴 🔴
</button> </button>
)} )}
@@ -10377,6 +10450,7 @@ function AppInner() {
className="ts-icon-button" className="ts-icon-button"
onClick={() => setTheme((mode) => (mode === "dark" ? "light" : "dark"))} onClick={() => setTheme((mode) => (mode === "dark" ? "light" : "dark"))}
title={t("toolbar.toggleTheme")} title={t("toolbar.toggleTheme")}
aria-label={t("toolbar.toggleTheme")}
> >
{theme === "dark" ? "☀️" : "🌙"} {theme === "dark" ? "☀️" : "🌙"}
</button> </button>