Skip to content

Commit 4380469

Browse files
committed
A11y: Fix color contrast and keyboard focus issues
- `.size-scanning`: `--color-text-tertiary` → `--color-text-secondary` for sufficient contrast on cursor-highlighted gold rows in dark mode (3.96:1 → 4.67:1) - `.ai-label`: `--color-cmdr-gold` → `--color-accent-text` for WCAG-compliant foreground gold on light backgrounds - Command palette `.results-container`: add `tabindex="-1"` to satisfy `scrollable-region-focusable` rule - Axe tests: exclude `[disabled]` elements (WCAG-exempt) from color-contrast checks - `setTheme()`: replace fixed 500ms sleep with `pollUntil` verifying `--color-bg-primary` matches expected value — fixes false positives from WKWebView theme-switch lag
1 parent 012b8f2 commit 4380469

4 files changed

Lines changed: 26 additions & 6 deletions

File tree

apps/desktop/src/lib/command-palette/CommandPalette.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
autocapitalize="off"
156156
/>
157157

158-
<div class="results-container" bind:this={resultsContainer} role="listbox" aria-label="Commands">
158+
<div class="results-container" bind:this={resultsContainer} role="listbox" aria-label="Commands" tabindex="-1">
159159
{#if results.length === 0 && query.trim()}
160160
<div class="no-results">No commands found</div>
161161
{:else}

apps/desktop/src/lib/file-explorer/views/FullList.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@
657657
}
658658
659659
.size-scanning {
660-
color: var(--color-text-tertiary);
660+
color: var(--color-text-secondary);
661661
font-size: var(--font-size-xs);
662662
white-space: nowrap;
663663
}

apps/desktop/src/lib/search/AiSearchRow.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
}
116116
117117
.ai-label {
118-
color: var(--color-cmdr-gold);
118+
color: var(--color-accent-text);
119119
}
120120
121121
.name-input {

apps/desktop/test/e2e-playwright/accessibility.spec.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,15 @@ async function runAxeAudit(
7777
}> {
7878
await injectAxe(tauriPage)
7979

80-
const axeCall = scope ? `axe.run(document.querySelector(${JSON.stringify(scope)}))` : 'axe.run()'
80+
// Exclude disabled elements from color-contrast checks — WCAG exempts them
81+
const axeConfig = JSON.stringify({
82+
rules: { 'color-contrast': { enabled: true } },
83+
checks: [{ id: 'color-contrast', options: { contrastRatio: { normal: { expected: 4.5 } } } }],
84+
exclude: [['[disabled]'], [':disabled']],
85+
})
86+
const axeCall = scope
87+
? `axe.run(document.querySelector(${JSON.stringify(scope)}), ${axeConfig})`
88+
: `axe.run(${axeConfig})`
8189
const results = await tauriPage.evaluate<AxeResults>(axeCall)
8290

8391
const critical = results.violations.filter((v) => v.impact === 'critical')
@@ -136,10 +144,22 @@ async function openSearchDialog(tauriPage: PageLike): Promise<void> {
136144
await tauriPage.waitForSelector('.search-overlay', 5000)
137145
}
138146

139-
/** Switch the app theme via Tauri's setTheme API. */
147+
/** Switch the app theme via Tauri's setTheme API and verify it applied. */
140148
async function setTheme(tauriPage: PageLike, mode: 'dark' | 'light'): Promise<void> {
141149
await tauriPage.evaluate(`window.__TAURI_INTERNALS__.invoke('plugin:app|set_app_theme', { theme: '${mode}' })`)
142-
await sleep(500) // Let the theme transition settle
150+
// Verify the theme actually applied by checking a CSS variable value.
151+
// WKWebView on macOS can be slow to update prefers-color-scheme after set_app_theme.
152+
const expectedBg = mode === 'light' ? '#ffffff' : '#1e1e1e'
153+
await pollUntil(
154+
tauriPage,
155+
async () => {
156+
const bg = await tauriPage.evaluate<string>(
157+
`getComputedStyle(document.documentElement).getPropertyValue('--color-bg-primary').trim()`,
158+
)
159+
return bg === expectedBg
160+
},
161+
3000,
162+
)
143163
}
144164

145165
// ── Tests ───────────────────────────────────────────────────────────────────

0 commit comments

Comments
 (0)