Skip to content

fix(a11y): fix color contrast in OlToggle sublabel and nav-bar work-menu (WCAG 1.4.3) - #13027

Merged
lokesh merged 2 commits into
masterfrom
a11y/contrast-fixes
Jul 3, 2026
Merged

fix(a11y): fix color contrast in OlToggle sublabel and nav-bar work-menu (WCAG 1.4.3)#13027
lokesh merged 2 commits into
masterfrom
a11y/contrast-fixes

Conversation

@mekarpeles

Copy link
Copy Markdown
Member

Summary

Two WCAG 1.4.3 (Contrast Minimum) violations fixed, both caught by axe-core in our Playwright a11y scans.

1. OlToggle.js — sublabel text

The toggle__sublabel (shows result count like "68" on search filters) used hardcoded #777 which computes to 4.47:1 against a white background — just below the 4.5:1 AA threshold.

Fix: --_toggle-sublabel-fg: #777--_toggle-sublabel-fg: var(--accessible-grey)

--accessible-grey (hsl(0, 0%, 46.3%)) is already defined in tokens/colors.css with a comment noting it's the minimum grey for white-background accessibility. CSS custom properties inherit through Shadow DOM, so this works correctly inside the Lit component.

2. nav-bar.css — work-menu selected tab

The selected book page nav tab (Overview, Editions, Details, etc.) used --blue-5e88B9 (hsl(212, 39%, 55%)) as background with white text — contrast 3.4:1, well below 4.5:1.

State Before Contrast After Contrast
Selected --blue-5e88B9 hsl(212,39%,55%) 3.4:1 ❌ --primary-blue hsl(202,96%,37%) 4.82:1 ✅
Hover hsl(212, 39%, 45%) (hardcoded) ~4.25:1 ❌ --header-nav-hover-color hsl(207,83%,33%) 6.56:1 ✅

Known pa11y-only issue (not in this PR)

.star.star--small gold (hsl(50, 100%, 50%)) on white = ~1.4:1. This is not caught by axe-core (axe skips the gradient/text-fill technique). The stars are decorative — the rating value is always conveyed in adjacent text. Fixing this requires a design decision (darken gold token or explicit pa11y exclusion for decorative elements). Tracked separately in #13009.

Test plan

Playwright regression tests (color-contrast.spec.ts) staged on branch 12885/playwright-e2e-tests (PR #12998). Both tests currently fail against openlibrary.org (confirming the violations exist); will pass once this PR deploys.

OL_BASE_URL=https://openlibrary.org npx playwright test a11y/color-contrast
# 2 failed (expected — violations present on live site)

Related

…G 1.4.3)

Two WCAG 1.4.3 (Contrast Minimum) violations fixed:

OlToggle.js: sublabel used hardcoded #777 (contrast 4.47:1, fails AA).
Changed to var(--accessible-grey) which is already defined in tokens
as the minimum accessible grey (hsl 0, 0%, 46.3% = 4.54:1 against white).

nav-bar.css (work-menu): selected tab used --blue-5e88B9 background
(hsl 212, 39%, 55%) with white text — contrast only 3.4:1. Changed to
--primary-blue (hsl 202, 96%, 37%, 4.82:1) for selected state and
--header-nav-hover-color (hsl 207, 83%, 33%, 6.56:1) for hover.

Note: .star.star--small gold color contrast (pa11y-only, not axe) is
a design decision tracked separately in #13009.

Playwright regression tests staged in #12998
(tests/e2e/a11y/color-contrast.spec.ts).

Fixes: color-contrast axe rule / WCAG 1.4.3
@mekarpeles mekarpeles added the Theme: Accessibility Work related to disability accessibility. [managed] label Jun 24, 2026
mekarpeles added a commit that referenced this pull request Jun 24, 2026
Playwright axe-core tests covering the fix in PR #13027:
- search page: OlToggle sublabel must pass 4.5:1 contrast
- work page: nav-bar selected tab must pass 4.5:1 contrast

Both tests currently fail against openlibrary.org (expected —
fix pending #13027 merge); will pass once the fix deploys.

@lokesh lokesh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

This change will not be discernible, but it will put us into compliance.

@lokesh
lokesh merged commit 15df1af into master Jul 3, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Theme: Accessibility Work related to disability accessibility. [managed]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants