@devries-cameron20 / t3code-1 / commits / 21e2b7de00
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): switches announce their real state to screen readers (#11580)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>

Khai Shern, Toh committed Sep 24, 2026 at 11:36 UTC 21e2b7de0062a3c1dca7209ca48b736dd9a36c84
2 files changed +24 -1
apps/web/src/components/ui/switch.test.tsx new
+20
@@ -0,0 +1,20 @@
1 +import { renderToStaticMarkup } from "react-dom/server";
2 +import { describe, expect, it } from "vite-plus/test";
3 +
4 +import { Switch } from "./switch";
5 +
6 +function renderSwitchRoot(props: Partial<Parameters<typeof Switch>[0]>) {
7 + const html = renderToStaticMarkup(<Switch aria-label="Enable Claude Code" {...props} />);
8 + return html.match(/<span[^>]*role="switch"[^>]*>/)?.[0] ?? "";
9 +}
10 +
11 +describe("Switch accessibility", () => {
12 + it("exposes the checked state to assistive tech", () => {
13 + expect(renderSwitchRoot({ checked: true })).toContain('aria-checked="true"');
14 + expect(renderSwitchRoot({ checked: false })).toContain('aria-checked="false"');
15 + });
16 +
17 + it("exposes the mixed state", () => {
18 + expect(renderSwitchRoot({ checked: false, mixed: true })).toContain('aria-checked="mixed"');
19 + });
20 +});
apps/web/src/components/ui/switch.tsx
+4 -1
@@ -27,7 +27,10 @@ function Switch({
27 data-size={size}
28 data-slot="switch"
29 data-mixed={mixed ? "" : undefined}
30 - aria-checked={mixed ? "mixed" : undefined}
30 + // Base UI copies every key we pass, even `undefined`, over its own
31 + // aria-checked. Only pass the attribute when mixed so the real state
32 + // survives for screen readers.
33 + {...(mixed ? { "aria-checked": "mixed" as const } : {})}
34 {...props}
35 >
36 <SwitchPrimitive.Thumb