Skip to content

fix(web): WCAG AA contrast in both themes, modal focus trap, skip link - #69

Merged
PastaPastaPasta merged 1 commit into
masterfrom
fix/web-a11y-contrast
Sep 27, 2026
Merged

PastaPastaPasta merged 1 commit into
masterfrom
fix/web-a11y-contrast

Conversation

@PastaPastaPasta

Copy link
Copy Markdown
Owner

Summary

Fixes D-046 (WCAG AA contrast) and D-047 (dialog focus, skip link, / to search). It also makes the dark/light/system theme toggle work, persist, and apply before first paint.

Contrast (D-046)

  • Tokens (tailwind.config.js, docs/design/style-guide.md):
    • anvil-500 is now #6b6460, which gives 5.3:1 on anvil-100; Tailwind's #78716c was 4.39:1.
    • caution and verify gain -400 (dark text) and -700 (light text) shades.
    • caution-700 is now #a14a08, because the old #b45309 was 3.95:1 on its own tint.
  • Class rewrites. Every low-contrast bare text class is now a light/dark pair:
    • text-caution, text-verify and text-danger become text-{state}-700 dark:text-{state}-400;
    • text-anvil-400 becomes text-anvil-500 dark:text-anvil-400;
    • text-forge-600 becomes text-forge-700, or text-forge-800 on an ember tint.
  • Specific fixes:
    • the network badge (#d97706 on #f7ede1, 2.75:1, on 24 pages) now clears 4.5:1;
    • the sign-in Import view (down to 1.63:1) now passes in both themes;
    • hljs comments and the home headline are fixed.
  • Scrollable regions. ScrollRegion makes code, diff and wide-table blocks keyboard-scrollable. It joins the Tab order only while its content overflows.
  • Colour-blind palette. The diff's A/D file letters now follow the blue/orange palette, where they used to be hard-coded green/red.

Keyboard (D-047)

  • components/ui/dialog.tsx:
    • Tab and Shift+Tab stay inside the dialog, and focus pulled behind it is brought back;
    • focus lands on the autoFocus field (the New-issue Title), not the panel;
    • on close, focus returns to the opener;
    • stacked dialogs are handled: only the top one answers keys;
    • the dialog is labelled with aria-labelledby and aria-describedby.
  • A "Skip to content" link is the first Tab stop and moves focus to <main>.
  • / focuses the jump box, but not while you are typing in a field. Escape blurs it.

Theme

  • The toggle cycles dark → light → system. The choice persists in localStorage.theme and next-themes applies it before first paint, so there is no flash.
  • QA's "light" axe runs rendered dark because prefers-color-scheme emulation doesn't switch an app whose default is dark. The specs now set the stored theme and assert on <html class>.

Tests

  • lib/design/contrast.test.ts:
    • semantic text pairs are checked on the surfaces and on their own 5–15 % tints;
    • there are checks for the muted and ember text shades;
    • a source guard fails on a light-theme text class that misses AA (aria-hidden icons are exempt).
  • e2e/a11y.spec.ts: axe on 22 routes plus the sign-in views, in both themes (46 tests).
    • Before this change: 25 failed.
    • After: all 46 pass.
  • e2e/keyboard-theme.spec.ts: skip link, /, the focus trap and restore on two dialogs, the three-state theme, no flash on load, and the colour-blind letters.
    • Before this change, against the master build: 6 of 7 fail. The seventh, the colour-blind letter test, also fails on master once it is pointed at a commit with added files, which is the version committed here.
    • After: 7 of 7 pass.
  • Typecheck, lint and vitest pass; the post-rebase numbers are under "Review and rebase" below.

QA (live, devnet moutai)

  • An axe matrix of 25 routes × 2 themes, 50 pages per run:

    Build Engine Viewport Pages with serious/critical issues
    master (before) chromium desktop 25
    this branch chromium desktop 0
    this branch chromium iPhone 13 0
    this branch firefox desktop 0
    this branch webkit desktop 0

    WebKit hung on one page load, the harness flake QA already recorded. I resumed that run in a fresh process for the remaining 15 pages.

  • Before/after screenshots, per-page axe JSON and the harness scripts are in dash-forge-qa/evidence/impl/ui-pass/a11y/.

Review (code-review-validator) and rebase

Rebased onto master after #51 (private repos) and #65. The colour codemod was re-run over the components #51 added: 47 lines in 9 files, including the private-members, merge-panel and private-banner views. The two conflicts were master's logic plus colour classes, resolved to master's code with the pairs applied.

The reviewer approved conditional on one blocking fix. Findings applied:

  • Blocking: a light-only hover:text-forge-800 on the commit page's parent links was 2.65:1 in dark mode. It now pairs with dark:hover:text-forge-400. A new test checks that every forge hover shade has a dark counterpart.
  • The codemod missed group-hover:text-forge-600 in the file list. The source guard now also matches hover: and group-hover: shades; it is shown to fail on the old code, and the two icon-only danger hovers are exempted by content, not line number.
  • Dialog under StrictMode:
    • React never writes autoFocus to the DOM, so the [autofocus] query was dead code. initialFocus now keeps focus where the autoFocus field put it.
    • The cleanup restores focus only on a real close (the panel has left the DOM), so StrictMode's simulated remount no longer pulls focus off the field.
    • Escape now ignores IME composition, and the no-op stopPropagation is gone.
    • Not verified in dev mode. I couldn't exercise this path in the dev server: next dev fails to hydrate at all under the app's <meta> CSP. Its dev bundle uses eval, which the CSP blocks (unsafe-eval is not allowed, by design). That problem already exists and has nothing to do with this PR. The production build, which is what ships and what the e2e specs test, passes.
  • Not taken: dark-mode hovers on untouched lines (toaster.tsx, copy-row.tsx, pulls-content.tsx), a follow-up; the ScrollRegion resize edge case (the props are static today).

After the rebase and fixes: typecheck, lint and vitest pass (1417 tests, 37 of them in the contrast file). e2e/a11y.spec.ts plus e2e/keyboard-theme.spec.ts pass 53/53 against the rebased build.

Not in this PR

  • Mobile layout, tap targets, and the phone funds cue (D-043) and spend ledger (D-044): these are a separate PR.
  • Slow 3G, the bundle split, and quorum refresh and degrade (D-025, D-024, D-058): these are a separate PR.

🤖 Generated with Claude Code

…k and / to search

D-046: text tokens gain light/dark AA pairs (anvil-500 #6b6460; caution/verify -400/-700), every bare low-contrast text class becomes a pair, hljs comments, the home headline, and diff A/D letters follow the colour-blind palette. Scroll regions (code, diffs, wide tables) take focus only while they overflow.

D-047: dialogs trap Tab/Shift+Tab, land on the autoFocus field, restore focus to the opener and stack; a skip-to-content link; / focuses the jump box. The theme toggle cycles dark/light/system.

Tests: contrast unit tests check tints and guard sources; e2e/a11y.spec.ts runs axe on every route in both themes; e2e/keyboard-theme.spec.ts covers focus, skip link, / and theming.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 27, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 56 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 675db0a7-1f0d-4380-843d-1ed582a15555

📥 Commits

Reviewing files that changed from the base of the PR and between 18aa2ab and a7d9fea.

📒 Files selected for processing (81)
  • docs/design/style-guide.md
  • forge-web/app/explore/page.tsx
  • forge-web/app/globals.css
  • forge-web/app/new/page.tsx
  • forge-web/app/notifications/page.tsx
  • forge-web/app/page.tsx
  • forge-web/app/settings/page.tsx
  • forge-web/components/app-header.tsx
  • forge-web/components/app-shell.tsx
  • forge-web/components/auth/create-identity-flow.tsx
  • forge-web/components/auth/protection-fields.tsx
  • forge-web/components/auth/wallet-connect-flow.tsx
  • forge-web/components/confirm-dialog.tsx
  • forge-web/components/display-prefs-panel.tsx
  • forge-web/components/encryption-key-panel.tsx
  • forge-web/components/funds-pill.tsx
  • forge-web/components/gateways-field.tsx
  • forge-web/components/key-top-up-dialog.tsx
  • forge-web/components/keys-panel.tsx
  • forge-web/components/login-modal.tsx
  • forge-web/components/markdown-view.tsx
  • forge-web/components/profile-content.tsx
  • forge-web/components/repo-card.tsx
  • forge-web/components/repo/approvals.tsx
  • forge-web/components/repo/blob-content.tsx
  • forge-web/components/repo/browse-boundary.tsx
  • forge-web/components/repo/clone-box.tsx
  • forge-web/components/repo/commit-content.tsx
  • forge-web/components/repo/commits-content.tsx
  • forge-web/components/repo/diff-view.tsx
  • forge-web/components/repo/file-list.tsx
  • forge-web/components/repo/fork-button.tsx
  • forge-web/components/repo/inline-comments.tsx
  • forge-web/components/repo/issue-content.tsx
  • forge-web/components/repo/issues-content.tsx
  • forge-web/components/repo/merge-panel.tsx
  • forge-web/components/repo/new-pull-content.tsx
  • forge-web/components/repo/new-release.tsx
  • forge-web/components/repo/path-breadcrumb.tsx
  • forge-web/components/repo/private-banner.tsx
  • forge-web/components/repo/private-members.tsx
  • forge-web/components/repo/pull-content.tsx
  • forge-web/components/repo/pull-diff.tsx
  • forge-web/components/repo/pulls-content.tsx
  • forge-web/components/repo/ref-list-content.tsx
  • forge-web/components/repo/ref-switcher.tsx
  • forge-web/components/repo/releases-content.tsx
  • forge-web/components/repo/repo-header.tsx
  • forge-web/components/repo/repo-home-content.tsx
  • forge-web/components/repo/repo-rail.tsx
  • forge-web/components/repo/settings-content.tsx
  • forge-web/components/repo/star-button.tsx
  • forge-web/components/repo/storage-unreachable.tsx
  • forge-web/components/repo/timeline.tsx
  • forge-web/components/spend-panel.tsx
  • forge-web/components/storage/copy-block.tsx
  • forge-web/components/storage/cost-card.tsx
  • forge-web/components/storage/profile-form.tsx
  • forge-web/components/storage/repo-storage-policy.tsx
  • forge-web/components/storage/storage-test.tsx
  • forge-web/components/storage/storage-wizard.tsx
  • forge-web/components/theme-toggle.tsx
  • forge-web/components/top-up-sheet.tsx
  • forge-web/components/ui/copy-link.tsx
  • forge-web/components/ui/copy-row.tsx
  • forge-web/components/ui/cost-preview.tsx
  • forge-web/components/ui/dialog.tsx
  • forge-web/components/ui/identity-pill.tsx
  • forge-web/components/ui/input.tsx
  • forge-web/components/ui/network-badge.tsx
  • forge-web/components/ui/oid.tsx
  • forge-web/components/ui/scroll-region.tsx
  • forge-web/components/ui/states.tsx
  • forge-web/components/ui/toaster.tsx
  • forge-web/components/ui/trust-panel.tsx
  • forge-web/components/ui/verification-chip.tsx
  • forge-web/e2e/a11y.spec.ts
  • forge-web/e2e/keyboard-theme.spec.ts
  • forge-web/lib/design/contrast.test.ts
  • forge-web/lib/focus.ts
  • forge-web/tailwind.config.js

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@PastaPastaPasta
PastaPastaPasta merged commit 98cbff3 into master Sep 27, 2026
5 checks passed
PastaPastaPasta added a commit that referenced this pull request Sep 27, 2026
Follows the contrast rules from #69: the create page's key notes and the sealed-limit overrun use the -700 / dark:-400 text shades, not the icon and border base colors.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant