Skip to content

Commit 37d36a3

Browse files
committed
fix(a11y): wire command palette tabs to active panel
1 parent 77e47ec commit 37d36a3

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

frontend/src/components/CommandPalette.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ export function CommandPalette() {
256256
[modeResultCounts]
257257
);
258258

259+
const modeTabId = `command-mode-tab-${mode}`;
260+
const modePanelId = `command-mode-panel-${mode}`;
261+
259262
const resultsSummary = useMemo(() => {
260263
if (mode === "global") {
261264
if (query.length < 2) return "Type 2+ characters to search across worlds";
@@ -438,11 +441,14 @@ export function CommandPalette() {
438441
{/* Mode toggle */}
439442
<div className="flex border-b border-hud-border" role="tablist" aria-label="Command palette modes">
440443
<button
444+
id="command-mode-tab-local"
441445
type="button"
442446
role="tab"
447+
tabIndex={mode === "local" ? 0 : -1}
443448
onClick={() => setMode("local")}
444449
title={`${modeMeta.local.label} · ${modeMeta.local.shortcut}`}
445450
aria-selected={mode === "local"}
451+
aria-controls="command-mode-panel-local"
446452
aria-label={`Local mode, ${modeResultLabels.local}`}
447453
className={`flex-1 py-1.5 font-mono text-sm uppercase tracking-[0.15em] ${
448454
mode === "local" ? "text-accent border-b border-accent" : "text-hud-muted"
@@ -451,11 +457,14 @@ export function CommandPalette() {
451457
LOCAL (${modeResultCounts.local})
452458
</button>
453459
<button
460+
id="command-mode-tab-global"
454461
type="button"
455462
role="tab"
463+
tabIndex={mode === "global" ? 0 : -1}
456464
onClick={() => setMode("global")}
457465
title={`${modeMeta.global.label} · ${modeMeta.global.shortcut}`}
458466
aria-selected={mode === "global"}
467+
aria-controls="command-mode-panel-global"
459468
aria-label={`Global mode, ${modeResultLabels.global}`}
460469
className={`flex-1 py-1.5 font-mono text-sm uppercase tracking-[0.15em] ${
461470
mode === "global" ? "text-accent border-b border-accent" : "text-hud-muted"
@@ -464,11 +473,14 @@ export function CommandPalette() {
464473
GLOBAL (${modeResultCounts.global})
465474
</button>
466475
<button
476+
id="command-mode-tab-taxonomy"
467477
type="button"
468478
role="tab"
479+
tabIndex={mode === "taxonomy" ? 0 : -1}
469480
onClick={() => setMode("taxonomy")}
470481
title={`${modeMeta.taxonomy.label} · ${modeMeta.taxonomy.shortcut}`}
471482
aria-selected={mode === "taxonomy"}
483+
aria-controls="command-mode-panel-taxonomy"
472484
aria-label={`Taxonomy mode, ${modeResultLabels.taxonomy}`}
473485
className={`flex-1 py-1.5 font-mono text-sm uppercase tracking-[0.15em] ${
474486
mode === "taxonomy" ? "text-accent border-b border-accent" : "text-hud-muted"
@@ -478,6 +490,12 @@ export function CommandPalette() {
478490
</button>
479491
</div>
480492

493+
<div
494+
id={modePanelId}
495+
role="tabpanel"
496+
aria-labelledby={modeTabId}
497+
className="contents"
498+
>
481499
<div className="flex items-center gap-3 border-b border-hud-border px-4 py-2 font-mono text-[11px] uppercase tracking-[0.15em] text-hud-label">
482500
<span>{t("shortcutLabel")}</span>
483501
<span className="text-hud-muted">{shortcutLabel} /</span>
@@ -764,6 +782,7 @@ export function CommandPalette() {
764782
})}
765783
</div>
766784
)}
785+
</div>
767786
</div>
768787
</div>
769788
);

0 commit comments

Comments
 (0)