Repository navigation
fix: Fix MobileTabBar active tab contrast and semantic nav landmark (OM-241) - #503
Conversation
| async function applyAppearance(colorTheme: ColorThemeId, mode: ThemeMode): Promise<void> { | ||
| const response = await api.patch('/api/settings', { data: { preferences: { theme: mode, colorTheme } } }) | ||
| if (!response.ok()) { | ||
| throw new Error(`appearance update failed: ${response.status()} ${await response.text()}`) | ||
| } | ||
| } |
There was a problem hiding this comment.
Shared state mutation
Each test saves the theme and color theme through the server-wide /api/settings preferences. The values are only reset in afterAll. If e2e specs run in parallel workers against the same backend, other specs can render with whatever theme this suite last applied. Two tests from this file could also overwrite each other's appearance between applyAppearance and the axe run. Consider forcing serial mode for this describe block (test.describe.configure({ mode: 'serial' })) and making sure no other spec runs at the same time and depends on the appearance settings.
| test.afterAll(async () => { | ||
| await api.patch('/api/settings', { data: { preferences: DEFAULT_APPEARANCE } }) | ||
| await api.dispose() | ||
| }) |
There was a problem hiding this comment.
Teardown masks errors
If beforeAll fails before api is assigned, afterAll calls api.patch on undefined and throws a TypeError that hides the original setup error. Guard the cleanup so it only runs when the context exists.
| test.afterAll(async () => { | |
| await api.patch('/api/settings', { data: { preferences: DEFAULT_APPEARANCE } }) | |
| await api.dispose() | |
| }) | |
| test.afterAll(async () => { | |
| if (!api) return | |
| await api.patch('/api/settings', { data: { preferences: DEFAULT_APPEARANCE } }) | |
| await api.dispose() | |
| }) |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
User description
Active tab labels in the mobile tab bar now meet WCAG AA contrast (4.5:1 or better) in dark mode, light mode and every selectable color theme. The bar is now a labelled
<nav>landmark, so assistive tech can find it and tell which tab is active. This fixes the 2.77:1color-contrastviolation (#1d4ed8on#131313, 12px text) that the design-system audit reported onschedules-mobileandrepo-schedules-mobile.What changed
frontend/src/components/navigation/MobileTabBar.tsxtext-foregroundinstead oftext-primary. Theborder-primaryunderline still marks the active tab. Only semantic theme tokens are used, with no hard-coded hex, so every theme gets the fix.TabBarRowrenders<nav aria-label={label}>instead of a<div>. The label is"Schedule navigation"in schedule mode (/repos/:id/schedules) and"Primary navigation"everywhere else.aria-current="true".frontend/src/components/navigation/MobileTabBar.test.tsx: tests now checkaria-currentandtext-foregroundinstead oftext-primary. New tests cover both landmarks and their labels.e2e/mobile-tab-bar-a11y.spec.ts(new): a Playwright suite at 390×844 with touch. It runs axe-corecolor-contrastandtarget-sizeon the tab bar for both mobile views in Manager dark and light. It also runscolor-contraston the active tab for every color theme (Manager plus all OpenCode themes) in both modes. Before running axe, it waits for CSS color transitions to finish after each theme switch.package.json/pnpm-lock.yaml: adds@axe-core/playwright@^4.14.1as a root dev dependency.Validation
Validation passed on commit
0378d752, and no fixes were needed:pnpm --filter frontend typecheckandpnpm lintwere clean.pnpm test:e2e:run e2e/mobile-tab-bar-a11y.spec.tshad 79 passed against the production build.aria-currentbehave correctly, including when you switch between schedule tabs. The active label renders in the foreground color with the primary underline. Axe found nocolor-contrastortarget-sizeviolations. The Sessions sheet still opens, and nothing overflows horizontally.origin/main: the MobileTabBar contrast violation on both mobile screens is gone and no new findings appeared.check_designreports the change conforms.Reviewer notes
pnpm-lock.yamlalso drops a number oflibc:lines on platform-specific packages. This is how the pinned pnpm version writes the lockfile, and the plan accepted it. Dependencies are unchanged apart from the new axe packages.#fafafa) is close to the inactive one (#d4d4d8), so the 2px primary underline does most of the visual work. The plan accepted this. The underline's non-text contrast is out of scope.text-primary. A pending design change on this task updates it totext-foreground border-primarywitharia-current, to apply after merge.ScheduleTabMenu(frontend/src/components/schedules/ScheduleTabMenu.tsx) still usestext-primaryfor its active 12px label (2.79:1, same onmain).RepoSchedulesContentresets to Jobs. This was already the case before this change.PR Type
Bug fix, Tests
Description
Fix active tab contrast using
text-foregroundAdd labelled
<nav>landmark witharia-currentAdd axe-core Playwright accessibility test suite
Update unit tests and add test dependency
Diagram Walkthrough
File Walkthrough
mobile-tab-bar-a11y.spec.ts
Add axe-core mobile tab bar accessibility e2e suitee2e/mobile-tab-bar-a11y.spec.ts
viewport.
color-contrastandtarget-sizerules on both mobileviews in dark and light modes.
themes.
analysis.
MobileTabBar.test.tsx
Update tab bar tests for landmarks and active statefrontend/src/components/navigation/MobileTabBar.test.tsx
text-primaryassertions withtext-foregroundandaria-currentchecks.
labels.
aria-current.MobileTabBar.tsx
Add nav landmark and accessible active tab stylingfrontend/src/components/navigation/MobileTabBar.tsx
text-primarytotext-foreground.TabBarRowas a<nav>with a mode-basedaria-label.aria-current="true"only to the active tab.MobileTabBarbased on route mode.package.json
Add axe-core Playwright dev dependencypackage.json
@axe-core/playwright@^4.14.1as a root dev dependency foraccessibility tests.