Skip to content

fix: Fix MobileTabBar active tab contrast and semantic nav landmark (OM-241) - #503

Merged
chriswritescode-dev merged 2 commits into
mainfrom
om-241-fix-mobiletabbar-active-tab-contrast-and
Dec 3, 2026
Merged

chriswritescode-dev merged 2 commits into
mainfrom
om-241-fix-mobiletabbar-active-tab-contrast-and

Conversation

@chriswritescode-dev

@chriswritescode-dev chriswritescode-dev commented Dec 3, 2026 •

Copy link
Copy Markdown
Owner

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:1 color-contrast violation (#1d4ed8 on #131313, 12px text) that the design-system audit reported on schedules-mobile and repo-schedules-mobile.

What changed

  • frontend/src/components/navigation/MobileTabBar.tsx
    • The active tab's text and icon use text-foreground instead of text-primary. The border-primary underline still marks the active tab. Only semantic theme tokens are used, with no hard-coded hex, so every theme gets the fix.
    • TabBarRow renders <nav aria-label={label}> instead of a <div>. The label is "Schedule navigation" in schedule mode (/repos/:id/schedules) and "Primary navigation" everywhere else.
    • Only the active tab gets aria-current="true".
  • frontend/src/components/navigation/MobileTabBar.test.tsx: tests now check aria-current and text-foreground instead of text-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-core color-contrast and target-size on the tab bar for both mobile views in Manager dark and light. It also runs color-contrast on 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.1 as a root dev dependency.

Validation

Validation passed on commit 0378d752, and no fixes were needed:

  • Frontend: navigation component tests passed (212 tests). pnpm --filter frontend typecheck and pnpm lint were clean.
  • New e2e suite: pnpm test:e2e:run e2e/mobile-tab-bar-a11y.spec.ts had 79 passed against the production build.
  • Browser checks on mobile: the landmark and aria-current behave correctly, including when you switch between schedule tabs. The active label renders in the foreground color with the primary underline. Axe found no color-contrast or target-size violations. The Sessions sheet still opens, and nothing overflows horizontally.
  • Desktop: no tab bar renders and the layout is unchanged.
  • Design-system audit against origin/main: the MobileTabBar contrast violation on both mobile screens is gone and no new findings appeared. check_design reports the change conforms.

Reviewer notes

  • Lockfile: pnpm-lock.yaml also drops a number of libc: 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.
  • Subtle active state: in Manager dark, the active label (#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.
  • Design doc update: the design-system item for tab states (STYLE-38) still says text-primary. A pending design change on this task updates it to text-foreground border-primary with aria-current, to apply after merge.
  • Not tested: WebKit, a real iOS device, and the rest of the e2e suite. Only the new spec ran end to end.
  • Out of scope, possible follow-ups:
    • The desktop ScheduleTabMenu (frontend/src/components/schedules/ScheduleTabMenu.tsx) still uses text-primary for its active 12px label (2.79:1, same on main).
    • On a repo's schedules page with no jobs, tapping Detail or Runs does nothing because RepoSchedulesContent resets to Jobs. This was already the case before this change.

PR Type

Bug fix, Tests


Description

  • Fix active tab contrast using text-foreground

  • Add labelled <nav> landmark with aria-current

  • Add axe-core Playwright accessibility test suite

  • Update unit tests and add test dependency


Diagram Walkthrough

flowchart LR
  A["MobileTabBar"] -- "active text and icon" --> B["text-foreground token"]
  A -- "container element" --> C["nav landmark"]
  C -- "aria-label by mode" --> D["Primary or Schedule navigation"]
  A -- "active tab state" --> E["aria-current=true"]
  F["MobileTabBar unit tests"] -- "verify landmark and contrast classes" --> A
  G["Playwright axe-core suite"] -- "checks color-contrast and target-size" --> A
  H["@axe-core/playwright dependency"] -- "enables" --> G
Loading

File Walkthrough

Relevant files
Tests
mobile-tab-bar-a11y.spec.ts
Add axe-core mobile tab bar accessibility e2e suite           

e2e/mobile-tab-bar-a11y.spec.ts
  • Adds a Playwright suite that checks tab bar accessibility at a mobile
    viewport.
  • Runs axe-core color-contrast and target-size rules on both mobile
    views in dark and light modes.
  • Verifies the active tab contrast across Manager and all OpenCode color
    themes.
  • Applies appearance settings and waits for CSS transitions before
    analysis.
+113/-0 
MobileTabBar.test.tsx
Update tab bar tests for landmarks and active state           

frontend/src/components/navigation/MobileTabBar.test.tsx
  • Replaces text-primary assertions with text-foreground and aria-current
    checks.
  • Adds tests for the Primary and Schedule navigation landmarks and
    labels.
  • Verifies inactive tabs do not receive aria-current.
+26/-4   
Bug fix
MobileTabBar.tsx
Add nav landmark and accessible active tab styling             

frontend/src/components/navigation/MobileTabBar.tsx
  • Changes the active tab text and icon from text-primary to
    text-foreground.
  • Renders TabBarRow as a <nav> with a mode-based aria-label.
  • Adds aria-current="true" only to the active tab.
  • Passes the navigation label from MobileTabBar based on route mode.
+7/-5     
Dependencies
package.json
Add axe-core Playwright dev dependency                                     

package.json
  • Adds @​axe-core/playwright@^4.14.1 as a root dev dependency for
    accessibility tests.
+1/-0     

Comment on lines +40 to +45
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()}`)
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment on lines +35 to +38
test.afterAll(async () => {
await api.patch('/api/settings', { data: { preferences: DEFAULT_APPEARANCE } })
await api.dispose()
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Suggested change
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()
})

@lil-worker-cstech

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⚠️ Risk checks: 2 finding(s) detected
Sensitive paths (2): package.json, pnpm-lock.yaml
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
⚠️ Risk level: Low
✅ Merge recommendation: Needs review
Merge recommendation checks
✅ CI on reviewed head: passed
✅ Head is current with its base: up to date
✅ Human authors: all authors are human
⚠️ No sensitive paths or risky changes: 2 finding(s)
⚠️ Changed lines within cap: 207 changed lines exceeds cap 100
🔎 Failure modes

What: Another e2e spec, or a test from this spec running in a different worker, sees the wrong theme or color theme. This spec saves `theme` and `colorTheme` through the shared `/api/settings` endpoint, so the change is global for the server, not limited to this test.
Where: e2e/mobile-tab-bar-a11y.spec.ts:applyAppearance
Trigger: Playwright runs spec files in parallel workers against the same backend, or `fullyParallel` is enabled, while this suite cycles through the color themes.
Detected by: Intermittent failures in other e2e specs that rely on the default Manager dark appearance, or `waitForAppearance` timing out in this spec.
Covered in this PR: No

What: `afterAll` throws `TypeError` on the undefined `api`, which hides the real setup error. It can also leave the server's appearance preferences changed if a test fails partway through.
Where: e2e/mobile-tab-bar-a11y.spec.ts:afterAll
Trigger: `playwrightRequest.newContext` fails in `beforeAll`, for example because the storage state file is missing.
Detected by: Playwright reports the teardown TypeError alongside the setup failure.
Covered in this PR: No

What: `waitForAppearance` never settles because the inline `--color-primary` value does not match `theme[mode].primary` exactly. A format difference such as rgb vs hex, or shorthand hex, is enough, and the test times out.
Where: e2e/mobile-tab-bar-a11y.spec.ts:waitForAppearance
Trigger: The theme applier normalizes or converts the primary color before writing it as an inline CSS variable.
Detected by: The `expect.poll` timeout in the per-theme contrast tests.
Covered in this PR: Yes

🧪 PR contains tests
🔒 No security concerns identified

@chriswritescode-dev
chriswritescode-dev merged commit 222d6a3 into main Dec 3, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant