Accessibility
The speaker's pages aim for WCAG 2.2 AA. They should work by keyboard alone, with a screen reader (VoiceOver, TalkBack, NVDA), with voice control, zoomed to 400 %, in Windows' forced colours, and with reduced motion. The Playwright specs check this on a desktop, a tablet and a phone; a change that breaks it fails them.
What the specs check
| Spec | Checks |
|---|---|
a11y.spec.ts | axe (WCAG 2.2 AA and best practices) on every page in light and dark mode. Also: the login page, including after a failed login; the page that is not there; the player idle and with a playlist; the TV's account with view and full access; the form for choosing a password; a speaker that does not answer; the open dialogs (confirmation, playlist name, song picker); the phone's open menu; a pale accent the owner chose. It also checks that nothing moves with reduced motion, the skip link, one h1 per page, and that every setting has a description. |
a11y-keyboard.spec.ts | The focus ring stands out at 3:1 or more in both modes and shows in forced colours. Focus stays on a switch, the mute button or a playlist's grip while the speaker answers, and moves to the next row or the list's heading when a song, a network or a folder goes away. The focused control is never under the volume bar. Field edges and switch tracks reach 3:1. |
a11y-names.spec.ts | On every page, a control's spoken name contains the words it shows (2.5.3), and every slider says its value in words. Volume says "Muted". Countdowns and the live log do not speak every second. A refused field is aria-invalid and names its error. The song picker says what a search found. |
layout.spec.ts | No sideways scrolling, touch targets of at least 44 × 44 px, and every page reflows to 320 px (1.4.10). |
bash
ddev playwright test Tests/playwright/specs/a11y.spec.ts Tests/playwright/specs/a11y-keyboard.spec.ts Tests/playwright/specs/a11y-names.spec.ts Tests/playwright/specs/layout.spec.tsThe shared helpers are in Tests/playwright/support/a11y.ts:
violations(page)runs axe with the project's tags;rendered(page)waits for the speaker's elements;deepActive(page)names the focused element through shadow roots.
Patterns for new controls
Most of these live in controls.ts and SpeakerElement, so a new element gets them by using the helpers.
- While waiting for the speaker, keep the focus. Use
aria-disabled=${unavailable(this.busy)}, not?disabled=${this.busy}.SpeakerElementswallows the clicks meanwhile.toggle()andaskFirst()take{ busy }. Keepdisabledfor controls that cannot be used for another reason, and say why in their description. - A control that goes away hands the focus on.
- Use
keepFocus(button, work)for a row's own action.askFirst()already does this. - Use
focusHeading(this.renderRoot)after showing other content, such as a folder or the list after a detail view.
- Use
- Every setting has a description: a
<p class="hint" id="…">andaria-describedbyon the control. - No
aria-labelthat drops the visible words. A label wrapping the control names it. Where anaria-labelis needed, for example to leave out a value shown beside the label, it must contain the label's words. Buttons may add context after them: "Add to playlist: Song". - Sliders say their value:
aria-valuetext. UsevolumeText()for volumes, and spell out units ("300 milliseconds"). - News goes into a region that is already there. Render
<div class="live" role="status">${notice}</div>always and change only what is inside. An empty.livetakes no room. Text that changes every second (countdowns, positions) stays out of live regions. - Errors about a field: the API answers with
field,errorLine(field)shows the error, andSpeakerElementmarks the field with thatnamearia-invalidand adds the error to its description. - Toggle buttons: a name that says the action ("Mute"/"Unmute"), or a fixed name with
aria-pressed, never both. - Colours: text tokens reach 4.5:1 and edges of controls 3:1 (
--boombox-control-border). An owner's accent is made readable byBrandTheme::readableAccent().
Checking by hand
The specs cannot hear a screen reader. Before a release, go through /, /playlists and /settings/audio with VoiceOver (⌘F5 on the Mac, or triple-click the side button on an iPhone):
- play and pause;
- change the volume;
- move a song in a playlist with the keyboard;
- delete a song and confirm.
Also press Tab through a page with the volume bar showing.