fix(a11y): names that carry what they show; the unused-key check stops covering whole files

- The palette launcher's name replaced its visible "Jump to…" (and the key cap's its "Ctrl K"):
  a voice-control "click Jump to" matched nothing (WCAG 2.5.3). Each name contains its text now.
- SegmentedToggle's `title` was only a tooltip on a non-focusable box — the live search's "how
  many per batch" hint reached no keyboard or screen-reader user. It is the group's accessible
  description, standalone and captioned alike.
- The unused-key contract let a template like `card.${status}` cover its whole namespace, which hid
  five dead keys (deleted). Dynamic keys are matched by shape (`editor.*.hint`); a bare namespace
  shape covers nothing, and the audit/quota namespaces are now held both ways by backendIds.
- CLAUDE.md's "FE control" row matches the lint rule it cites; each no-restricted-syntax entry has
  its reason directly above it.
This commit is contained in:
2026-09-19 19:19:43 +02:00
parent fa4f823fc8
commit cf0c55ba80
13 changed files with 128 additions and 39 deletions
+3 -5
View File
@@ -446,14 +446,12 @@ export default function Feed({
{zeroQuota ? t("feed.yt.freeNote") : t("feed.yt.quotaNote")}
</span>
{/* Four fixed counts: the house's segmented control, not a native <select> (owner's
pick, 2026-09-19). The caption is the group's name; the hint rides on the row. */}
<div
className="ml-auto flex items-center gap-1.5 text-xs text-muted shrink-0"
title={t("feed.yt.showHint")}
>
pick, 2026-09-19). The caption is the group's name, the hint its description. */}
<div className="ml-auto flex items-center gap-1.5 text-xs text-muted shrink-0">
<span aria-hidden="true">{t("feed.yt.show")}</span>
<SegmentedToggle
ariaLabel={t("feed.yt.show")}
title={t("feed.yt.showHint")}
value={String(ytCount)}
onChange={(v) => setYtCount(Number(v))}
options={YT_COUNTS.map((n) => ({ value: String(n), label: String(n) }))}
@@ -54,8 +54,9 @@ describe("the command palette's visible entry", () => {
it("is a key cap inside the search field, naming the chord the palette row binds", () => {
page = "feed";
const isOpen = mount();
const cap = screen.getByRole("button", { name: "palette.open" });
expect(cap.textContent).toMatch(/^(Ctrl|⌘) K$/);
const cap = screen.getByRole("button", { name: /^palette\.open \((Ctrl|⌘) K\)$/ });
// Label in Name: the name carries what the cap shows, so "click Ctrl K" finds it.
expect(cap.getAttribute("aria-label")).toContain(cap.textContent);
expect(screen.getByRole("textbox")).toBeTruthy();
fireEvent.click(cap);
expect(isOpen()).toBe(true);
@@ -65,8 +66,9 @@ describe("the command palette's visible entry", () => {
page = "home";
const isOpen = mount();
expect(screen.queryByRole("textbox")).toBeNull();
const pill = screen.getByRole("button", { name: "palette.open" });
expect(pill.textContent).toContain("palette.title");
// Named by what it shows ("Jump to…"), not by a label that replaced it.
const pill = screen.getByRole("button", { name: "palette.title" });
expect(pill.getAttribute("title")).toBe("palette.open");
fireEvent.click(pill);
expect(isOpen()).toBe(true);
});
+6 -2
View File
@@ -20,6 +20,10 @@ function useCap(): string {
});
}
// Each accessible name CONTAINS what the control shows (WCAG 2.5.3, Label in Name): a voice-control
// user says what they see — "click Jump to", "click Ctrl K" — and a name that replaced the visible
// words matched nothing.
/** The key cap at the end of a search field. A button, so the pointer and a screen reader reach it
* too; left out of a phone's narrow header, where there is no keyboard to press it on. */
export function PaletteKeycap() {
@@ -29,7 +33,7 @@ export function PaletteKeycap() {
<button
type="button"
onClick={openPalette}
aria-label={t("palette.open")}
aria-label={`${t("palette.open")} (${cap})`}
title={t("palette.open")}
className="shrink-0 rounded-md border border-border px-1.5 py-0.5 font-mono text-3xs text-muted transition hover:border-accent/50 hover:text-fg @max-[640px]/appmain:hidden"
>
@@ -46,7 +50,7 @@ export function PaletteLauncher() {
<button
type="button"
onClick={openPalette}
aria-label={t("palette.open")}
title={t("palette.open")}
className="pointer-events-auto glass-menu flex h-11 items-center gap-2 rounded-2xl px-3 text-sm text-muted transition hover:text-fg"
>
<Command className="h-4 w-4 shrink-0" aria-hidden="true" />
@@ -69,4 +69,39 @@ describe("SegmentedToggle", () => {
expect(screen.getByTestId("ic-my")).toBeTruthy();
expect(screen.getByRole("button", { name: "Mine" }).getAttribute("title")).toBe("Your subs");
});
// The hint was a `title` on a non-focusable box: the pointer's tooltip, and nothing at all for a
// keyboard or screen-reader user (deep review, debt burn). It is the group's description now.
it("describes the group by its title, standalone and captioned alike", () => {
render(
<>
<SegmentedToggle
options={OPTS}
value="or"
onChange={vi.fn()}
ariaLabel="Show"
title="Results per batch"
/>
<SegmentedToggle
options={OPTS}
value="or"
onChange={vi.fn()}
ariaLabel="Match"
label="Match"
title="Any or all"
/>
</>,
);
expect(
screen.getByRole("group", { name: "Show", description: "Results per batch" }),
).toBeTruthy();
expect(screen.getByRole("group", { name: "Match", description: "Any or all" })).toBeTruthy();
});
it("adds no description without a title", () => {
render(<SegmentedToggle options={OPTS} value="or" onChange={vi.fn()} ariaLabel="Match" />);
expect(screen.getByRole("group", { name: "Match" }).hasAttribute("aria-describedby")).toBe(
false,
);
});
});
+13 -2
View File
@@ -1,4 +1,4 @@
import { type ReactNode } from "react";
import { useId, type ReactNode } from "react";
// Shared MATCH / segmented primitive — a rounded-full pill track where exactly ONE option is active
// (radio-like). Backs the feed any/all + or/and "Match" toggles and the feed Mine/Library scope bar,
@@ -31,13 +31,17 @@ export default function SegmentedToggle<T extends string>({
// Optional left-hand caption; when set the control renders as a justify-between row (the feed/Plex
// "Match" toggles). Omit for a standalone bar (the Mine/Library scope switch).
label?: ReactNode;
title?: string; // tooltip on the whole row (caption mode only)
// What the choice means, beyond its name: the row's tooltip for the pointer, and the group's
// accessible description for the keyboard and a screen reader — a `title` on a non-focusable box
// alone reaches neither (it had only ever been the pointer's).
title?: string;
// Full-width track with flex-1 buttons (the scope bar); default is intrinsic width.
fullWidth?: boolean;
// sm = text-3xs, compact padding (the captioned match toggles); md = text-xs (the scope bar).
size?: "sm" | "md";
className?: string;
}) {
const hintId = useId();
const track = (
<div
className={`inline-flex items-center rounded-full border border-border bg-card p-0.5 ${
@@ -45,7 +49,14 @@ export default function SegmentedToggle<T extends string>({
}${fullWidth ? " w-full" : ""}`}
role="group"
aria-label={ariaLabel}
aria-describedby={title ? hintId : undefined}
title={label == null ? title : undefined}
>
{title && (
<span id={hintId} hidden>
{title}
</span>
)}
{options.map((o) => (
<button
key={o.value}