From a5fc204de815a294d4f830197594e461c12bf4b7 Mon Sep 17 00:00:00 2001 From: poli0981 <127664709+poli0981@users.noreply.github.com> Date: Tue, 10 Nov 2026 18:55:30 +0700 Subject: [PATCH] fix(a11y): mark destructive controls by attribute for high contrast (U45) Forced-colors drops every tint, so a danger-treated primary is drawn exactly like the Cancel beside it. The stylesheet gave five data-action values a border and had missed Remove, Allow, Clear, the Force-latest confirm and a forced plan's Confirm for as long as the list existed. The mark is one attribute, data-destructive, and destructive.test.ts reads the source to hold both halves: every button drawn in the danger colour carries it, and the stylesheet draws it. The active sidebar tab carries aria-current="page" and the outline rule matched 'true', so high contrast drew it like every other tab. Co-Authored-By: Claude Fable 5.2 --- ui/src/components/PdCacheUsage.tsx | 1 + ui/src/components/PdSummarySheet.tsx | 1 + ui/src/components/PdUninstallDialog.tsx | 2 + ui/src/destructive.test.ts | 91 +++++++++++++++++++++++++ ui/src/screens/PdEnvDetail.tsx | 1 + ui/src/screens/PdEnvironments.tsx | 2 + ui/src/screens/PdHealth.tsx | 1 + ui/src/screens/PdPlanPanel.tsx | 4 ++ ui/src/screens/PdSettings.tsx | 1 + ui/src/styles.css | 18 +++-- 10 files changed, 115 insertions(+), 7 deletions(-) create mode 100644 ui/src/destructive.test.ts diff --git a/ui/src/components/PdCacheUsage.tsx b/ui/src/components/PdCacheUsage.tsx index 0ce4198..1d5d677 100644 --- a/ui/src/components/PdCacheUsage.tsx +++ b/ui/src/components/PdCacheUsage.tsx @@ -160,6 +160,7 @@ export function PdCacheUsage() { void doClear(confirming) }} data-action="confirm-clear-cache" + data-destructive className="rounded-pd border border-danger px-3 py-1 text-data text-danger disabled:opacity-40" > {t('cache.clear')} diff --git a/ui/src/components/PdSummarySheet.tsx b/ui/src/components/PdSummarySheet.tsx index 33fc3a4..f24ec49 100644 --- a/ui/src/components/PdSummarySheet.tsx +++ b/ui/src/components/PdSummarySheet.tsx @@ -113,6 +113,7 @@ export function PdSummarySheet({ outcome, onDone, onRollback }: PdSummarySheetPr onRollback(snapshot.id) }} data-action="rollback" + data-destructive className="rounded-pd border border-danger px-2 py-0.5 text-data text-danger" > {t('snapshots.rollbackThis')} diff --git a/ui/src/components/PdUninstallDialog.tsx b/ui/src/components/PdUninstallDialog.tsx index d27b84b..fd4bfa3 100644 --- a/ui/src/components/PdUninstallDialog.tsx +++ b/ui/src/components/PdUninstallDialog.tsx @@ -64,6 +64,7 @@ export function PdUninstallDialog({ onConfirm(false) }} data-action="remove" + data-destructive className="rounded-pd border border-danger px-3 py-1 text-data text-danger disabled:opacity-40" > {t('uninstall.remove', { count: report.removing.length })} @@ -88,6 +89,7 @@ export function PdUninstallDialog({ onConfirm(true) }} data-action="force" + data-destructive className="rounded-pd border border-danger bg-danger/15 px-3 py-1 text-data text-danger disabled:opacity-40" > {t('uninstall.force', { count: report.removing.length })} diff --git a/ui/src/destructive.test.ts b/ui/src/destructive.test.ts new file mode 100644 index 0000000..b806e4e --- /dev/null +++ b/ui/src/destructive.test.ts @@ -0,0 +1,91 @@ +/** + * Every destructive control says so in an attribute, and high contrast draws it — UI-SPEC §7. + * + * Forced-colors drops every tint, so a danger-treated primary is drawn exactly like the Cancel + * beside it unless something that survives the mode marks it. The stylesheet used to do that with + * a hand-kept list of five `data-action` values, and the list was wrong for as long as it existed: + * *Remove*, *Allow*, *Clear*, the *Force latest* confirm and a forced plan's *Confirm* were never + * on it (audit backlog U45). A list of names beside a list of buttons is two lists. + * + * So the mark is one attribute, `data-destructive`, and this reads the source to hold both halves: + * every button drawn in the danger colour carries it, and the stylesheet draws it. jsdom applies + * no stylesheet and has no forced-colors, so there is nothing to render — the source is the only + * place either fact exists before the hand pass. + */ + +import { readFileSync } from 'node:fs' +import { resolve } from 'node:path' + +import { describe, expect, it } from 'vitest' + +const sources = import.meta.glob(['./**/*.tsx', '!./**/*.test.tsx'], { + query: '?raw', + import: 'default', + eager: true, +}) +// Read from disk: vitest hands a test an empty string for any `.css` import, `?raw` included. +// From the working directory, which `vite.config.ts` pins to the repository root — under jsdom +// `import.meta.url` is not a `file:` URL to resolve against. +const styles = readFileSync(resolve(process.cwd(), 'ui/src/styles.css'), 'utf8') + +/** The opening tag of every `