Mark required fields consistently and accessibly #682

Open
opened 2026-11-13 16:51:50 +01:00 by simon · 1 comment
Owner

Motivation

<.input> marks a required field with a red asterisk after the label; the asterisk is hidden from screen readers and the field carries aria-required (lib/mv_web/components/form.ex). No form explains what the asterisk means, and forms mark required fields only, never optional ones. DESIGN_GUIDELINES §6.3 asks for a consistent indicator plus accessible text. Checked on main 777fc938.

Decision to make

The sources disagree:

Options:

  • a) keep today's asterisk and aria-required, and add one "* required field" note per form;
  • b) mark optional fields "(optional)" instead;
  • c) both.

Mila mixes mostly-optional forms (member) and mostly-required forms (settings); count required and optional fields per form before deciding.

Scope

lib/mv_web/components/form.ex (all <.input> variants), every form, the component showcase, and DESIGN_GUIDELINES §6.3. Measure the contrast of the marker in both themes.

Acceptance criteria

  • Every form marks required (or optional) fields the same way, as decided.
  • The meaning of the marker is stated in visible text, not only as a symbol.
  • The marker meets WCAG AA contrast in light and dark theme.
  • §6.3 describes the rule.

Dependencies

  • Before #670 (public join form) and #678 (per-section edit forms): both build forms and should use the decided rule. The join form is filled by applicants on a phone, mostly once; count its required and optional fields too.
## Motivation `<.input>` marks a required field with a red asterisk after the label; the asterisk is hidden from screen readers and the field carries `aria-required` (`lib/mv_web/components/form.ex`). No form explains what the asterisk means, and forms mark required fields only, never optional ones. DESIGN_GUIDELINES §6.3 asks for a consistent indicator plus accessible text. Checked on `main` 777fc938. ## Decision to make The sources disagree: - GOV.UK (Question pages): never mark mandatory fields with asterisks; mark optional fields with "(optional)". https://design-system.service.gov.uk/patterns/question-pages/ - Nielsen Norman Group (Marking required fields): mark every required field; the asterisk is common and understood; people do not read instructions at the top of forms. https://www.nngroup.com/articles/required-fields/ Options: - a) keep today's asterisk and `aria-required`, and add one "* required field" note per form; - b) mark optional fields "(optional)" instead; - c) both. Mila mixes mostly-optional forms (member) and mostly-required forms (settings); count required and optional fields per form before deciding. ## Scope `lib/mv_web/components/form.ex` (all `<.input>` variants), every form, the component showcase, and DESIGN_GUIDELINES §6.3. Measure the contrast of the marker in both themes. ## Acceptance criteria - Every form marks required (or optional) fields the same way, as decided. - The meaning of the marker is stated in visible text, not only as a symbol. - The marker meets WCAG AA contrast in light and dark theme. - §6.3 describes the rule. ## Dependencies - Before #670 (public join form) and #678 (per-section edit forms): both build forms and should use the decided rule. The join form is filled by applicants on a phone, mostly once; count its required and optional fields too.
Author
Owner

Scope extension (planning, 2026-11-19): #682 touches every form and the <.input> component anyway. Two more form-wide problems belong into the same change, so the forms are reworked once:

1. Submit buttons flicker on fast saves. Every submit button swaps its label while the form is sent (phx-disable-with, "Save" → "Saving..."). On a fast save the user sees a ~35 ms flash and the button grows (113 → 129 px on the data field page, Firefox 1280 px), then jumps back. DESIGN_GUIDELINES §5.6 requires phx-disable-with, so this happens in about 18 places.

  • Goal: a fast save changes neither label nor width (a second submit is still blocked); a slow action (import, test mail, sync) shows progress after a delay; the button keeps its width.
  • Options to decide with mockups: (A) label stays, spinner inside the button after ~300–400 ms via phx-submit-loading; (B) delayed label swap with reserved width; (C) label swap only for long-running actions. GOV.UK prevents double submit without a label change.
  • One shared place (component or app.css), all call sites moved, §5.6 updated; aria-busy or a polite live message when it takes a while.

2. Field borders are too faint. Checkbox and text input borders measure about 1.5:1 against the background app-wide (WCAG 1.4.11 asks 3:1 for the boundary of a control; only the radio was raised in #669). Raise them in the shared component/theme tokens, light and dark, and measure all <.input> variants.

Additional acceptance criteria:

  • On a fast save (< 300 ms) neither label nor width of the submit button changes; a second submit is blocked; a slow action (simulated ≥ 1 s) shows progress with unchanged width.
  • No phx-disable-with left in lib/ unless DESIGN_GUIDELINES names the exception.
  • Every <.input> variant has a control boundary of at least 3:1 in light and dark (measured values in the PR).
  • Checked in Firefox and Chromium, desktop and 390 px, reduced motion respected.
Scope extension (planning, 2026-11-19): #682 touches every form and the `<.input>` component anyway. Two more form-wide problems belong into the same change, so the forms are reworked once: **1. Submit buttons flicker on fast saves.** Every submit button swaps its label while the form is sent (`phx-disable-with`, "Save" → "Saving..."). On a fast save the user sees a ~35 ms flash and the button grows (113 → 129 px on the data field page, Firefox 1280 px), then jumps back. DESIGN_GUIDELINES §5.6 requires `phx-disable-with`, so this happens in about 18 places. - Goal: a fast save changes neither label nor width (a second submit is still blocked); a slow action (import, test mail, sync) shows progress after a delay; the button keeps its width. - Options to decide with mockups: (A) label stays, spinner inside the button after ~300–400 ms via `phx-submit-loading`; (B) delayed label swap with reserved width; (C) label swap only for long-running actions. GOV.UK prevents double submit without a label change. - One shared place (component or `app.css`), all call sites moved, §5.6 updated; `aria-busy` or a polite live message when it takes a while. **2. Field borders are too faint.** Checkbox and text input borders measure about 1.5:1 against the background app-wide (WCAG 1.4.11 asks 3:1 for the boundary of a control; only the radio was raised in #669). Raise them in the shared component/theme tokens, light and dark, and measure all `<.input>` variants. Additional acceptance criteria: - [ ] On a fast save (< 300 ms) neither label nor width of the submit button changes; a second submit is blocked; a slow action (simulated ≥ 1 s) shows progress with unchanged width. - [ ] No `phx-disable-with` left in `lib/` unless DESIGN_GUIDELINES names the exception. - [ ] Every `<.input>` variant has a control boundary of at least 3:1 in light and dark (measured values in the PR). - [ ] Checked in Firefox and Chromium, desktop and 390 px, reduced motion respected.
Sign in to join this conversation.
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
local-it/mitgliederverwaltung#682
No description provided.