Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,7 @@ Our goal is WCAG 2.1 level AA. We design for users with reduced vision, hearing,

### Some known gaps

- VoiceOver has been run automated (11 of 15 steps passed, see the [VoiceOver report](docs/voiceover-report.md)), but not yet by hand. Empty required fields are read as «invalid data» before the user has done anything. See [screen reader testing](docs/screen-reader.md).
- eslint-plugin-jsx-a11y is not set up yet.
- VoiceOver has been tested on macOS with Safari, automated and by hand. NVDA on Windows and VoiceOver on iPhone are not tested yet. See [screen reader testing](docs/screen-reader.md).- eslint-plugin-jsx-a11y is not set up yet.

## Sustainability

Expand Down
11 changes: 7 additions & 4 deletions docs/screen-reader.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,17 @@ For each step, write down what VoiceOver says if it differs from the expected re
| Date | How | Browser and screen reader | Result |
| ----------- | ------------------------------ | ----------------------------------- | ------------------------------------------------------------- |
| 16 Nov 2026 | Automated, `npm run voiceover` | WebKit 27.2 + VoiceOver, macOS 26.6 | 11 of 15 steps passed. See the [report](voiceover-report.md). |
| | By hand | Safari + VoiceOver (macOS) | Not run yet |
| 25 Nov 2026 | By hand, on the VM | Safari + VoiceOver (macOS) | Steps 1–5 and 15 passed, step 2 with a note (see below). Steps 6–14 not run. Found: empty required fields are read as «kreves, ugyldige data». |
| 26 Nov 2026 | By hand, locally with the fix | Safari + VoiceOver (macOS) | All 15 steps passed. Empty required fields are no longer read as invalid. |

## What the VoiceOver run found

Fixed:

- **Lists were not read as lists.** Safari and VoiceOver ignore the list role on a `<ul>` or `<ol>` without bullets (`list-style: none`), unless it is inside `<nav>` or has `role="list"`. The suggestions on the front page were read as «group» instead of «list, 5 items», and the same went for search results, filters, reviews and categories. All 11 lists now have `role="list"`, and `src/test/listRoles.test.ts` fails if a new list does not.

- **«invalid data» before the user had done anything.** Safari reads an empty `required` field as invalid unless `aria-invalid` says otherwise. The login fields and the stars now always have `aria-invalid`, which is `false` until a failed attempt. VoiceOver now reads «Brukernavn, kreves, tekstfelt» and «0,5 av 5 stjerner, kreves, valgknapp, 1 av 10». ARIA 1.2 does not list `aria-invalid` for radio buttons, but Safari still uses it, as the run by hand on 26 November showed. `AuthForm.test.tsx` and `ReviewForm.test.tsx` fail without the fix.

Confirmed with VoiceOver: the focus fixes above work. After removing the last filter, VoiceOver says «heading level 1, Utforsk viner», then the new number of hits. After saving a review it says «Oppdater dommen, button», then «Dommen er lagret.» The live regions for search results, reviews, «Vil prøve» and failed login are all read. The field rules are read with the fields: «Brukernavn, 3–30 tegn: små bokstaver, tall og understrek.»

The four steps that failed, and what they mean:
Expand All @@ -97,10 +100,10 @@ The four steps that failed, and what they mean:
| 2. Tab from the top | Tab went to the search field, not to «Hopp til hovedinnhold». | Safari's default: Tab skips links unless «Press Tab to highlight each item» is on, or the user presses Option + Tab. VoiceOver users move with VO + arrows, where the skip link is the first item (step 1). Not a bug in the app. |
| 3. Search and press Enter | VoiceOver read «Viser 18 av 18 viner for «pinot»», but the h1 «Utforsk viner» was not recorded. | The h1 gets focus (the e2e test checks it, and step 6 hears it). The live region probably cut the heading off, or the script missed a short phrase. Check by hand. |
| 5. Tick «Rødvin» | «unchecked» was heard, but from moving focus to the box before Space. After Space only the new number of hits was recorded. | The script is too strict. In the dialog (step 14) VoiceOver says «checked, Rødvin, 11 viner» after Space, so the state is read. Check by hand in the sidebar. |
| 15. Offline | The banner «Du er frakoblet» was not recorded. The error «Du er ikke koblet til internett» and «Du er på nett igjen.» were. | The user is told about the problem when it matters. Check by hand whether the banner is announced when the network goes. |
| 15. Offline | The banner «Du er frakoblet» was not recorded. The error «Du er ikke koblet til internett» and «Du er på nett igjen.» were. | The user is told about the problem when it matters. Check by hand whether the banner is announced when the network goes. |

Not fixed yet:
All four work when checked by hand. On 25 November, steps 3, 5 and 15 passed. In step 2, Tab went to the second link, because VoiceOver already stood on the skip link when the page loaded. Shift + Tab reached it, and Enter went to the main content. On 26 November, Tab went straight to «Hopp til hovedinnhold».

- **«invalid data» before the user has done anything.** Fields with `required` are read as «required, invalid data» while they are still empty, for example the star rating and the login fields. That can make a user think they did something wrong. One fix is to check the fields ourselves on submit instead of using `required`, and set `aria-invalid` only after a failed attempt.
In Safari, Tab also skips the stars, for the same reason as in step 2. VoiceOver users reach them with VO + arrows.

If there is time, also test with NVDA and Firefox on Windows, and VoiceOver on an iPhone.
9 changes: 8 additions & 1 deletion frontend/src/features/auth/components/AuthForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,17 @@ describe('AuthForm', () => {
await user.click(screen.getByRole('button', { name: 'Lag bruker' }));
await user.type(usernameField(), 'k');

expect(usernameField()).not.toHaveAttribute('aria-invalid');
expect(usernameField()).toHaveAttribute('aria-invalid', 'false');
expect(screen.queryByText('Skriv inn brukernavn.')).not.toBeInTheDocument();
});

it('does not mark the empty fields as invalid before the user has tried to log in', () => {
renderForm('login');

expect(usernameField()).toHaveAttribute('aria-invalid', 'false');
expect(passwordField()).toHaveAttribute('aria-invalid', 'false');
});

it('puts an API error about a field next to that field', async () => {
const { user } = renderForm('register', {
field: 'username',
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/features/auth/components/AuthForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export function AuthForm({ mode, onSubmit }: AuthFormProps) {
autoCapitalize="none"
spellCheck={false}
required
aria-invalid={fieldErrors.username ? true : undefined}
aria-invalid={Boolean(fieldErrors.username)}
aria-describedby={describedBy('username')}
/>
{fieldErrors.username && (
Expand All @@ -149,7 +149,7 @@ export function AuthForm({ mode, onSubmit }: AuthFormProps) {
className={styles.input}
autoComplete={isRegister ? 'new-password' : 'current-password'}
required
aria-invalid={fieldErrors.password ? true : undefined}
aria-invalid={Boolean(fieldErrors.password)}
aria-describedby={describedBy('password')}
/>
{fieldErrors.password && (
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/features/wine/components/ReviewForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,14 @@ describe('ReviewForm', () => {
expect(onSave).toHaveBeenCalledWith({ rating: 4, comment: 'Fin til pizza' });
});

it('does not save without stars', async () => {
it('does not save without stars, and only then marks the stars as invalid', async () => {
const { user, onSave } = renderForm();
const firstStar = screen.getByRole('radio', { name: '0,5 av 5 stjerner' });
expect(firstStar).toHaveAttribute('aria-invalid', 'false');

await user.click(screen.getByRole('button', { name: 'Lagre dommen' }));
expect(onSave).not.toHaveBeenCalled();
expect(firstStar).toHaveAttribute('aria-invalid', 'true');
});

it('shows the saved review and can delete it', async () => {
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/features/wine/components/ReviewForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export function ReviewForm({ myReview, saving, onSave, onDelete }: ReviewFormPro
const [rating, setRating] = useState<number | null>(myReview?.rating ?? null);
const [hovered, setHovered] = useState<number | null>(null);
const [comment, setComment] = useState(myReview?.comment ?? '');
const [triedWithoutRating, setTriedWithoutRating] = useState(false);
const commentId = useId();
const countId = useId();

Expand Down Expand Up @@ -57,6 +58,8 @@ export function ReviewForm({ myReview, saving, onSave, onDelete }: ReviewFormPro
onChange={() => setRating(value)}
className={styles.radio}
required
onInvalid={() => setTriedWithoutRating(true)}
aria-invalid={triedWithoutRating && rating === null}
/>
<span className="sr-only">{formatStars(value)} av 5 stjerner</span>
</label>
Expand Down