Skip to content

fix(ui): announce form errors, manage focus, respect reduced motion #102

Closed

Description

@Ardnived

Summary

Three accessibility groups from the release-readiness review (.claude/reports/RELEASE_READINESS.md §5, Appendix C), kept as one ticket because they share files and subsystem: (1) per-field form validation errors are never announced to assistive tech and focus does not move to the first invalid field on submit — a concrete WCAG 4.1.3/3.3.1 failure; (2) prefers-reduced-motion is completely unimplemented — zero hits repo-wide — so drawers, peek strips and map fly arcs animate unconditionally; (3) a focus/label polish set: PeekStrip focus + duplicate names, Chip close focus ring, Spinner's hard-coded English SR text, ContactPopover focus management, and the English-only Mapbox GeolocateControl label.

Proposed changes

1. Announce form errors + focus the first invalid field (WCAG 4.1.3 / 3.3.1)

src/components/molecules/FormField/FormField.tsx:69-73 — the per-field error span carries fieldErrorId(htmlFor) for the aria-describedby contract but has no live semantics: nothing is announced when validation fails. And src/components/organisms/RegistrationForm/RegistrationForm.tsx never moves focus to the first invalid field on submit (no setFocus anywhere; useForm at :111, handleSubmit at :155).

  • Add a live-region or role="alert" strategy for field errors that does not over-announce: announce on submit, not per keystroke (react-hook-form's default mode: 'onSubmit' helps; the alert semantics must not re-fire on every re-render).
  • Move focus to the first invalid field on submit in RegistrationForm via react-hook-form's setFocus (RHF auto-focuses only plain registered inputs — verify whether the form's controlled/custom atoms defeat that and wire setFocus in the onInvalid path accordingly).
  • Keep the existing fieldErrorId / fieldHelpId / fieldDescribedBy id contract intact (FormField.tsx:8-33) — every form atom points at it (report Appendix C row "isInvalid/aria-describedby contract").

2. Respect prefers-reduced-motion (WCAG 2.3.3)

Zero prefers-reduced-motion / MotionConfig / reducedMotion hits across src/ and tailwind.config.js (verified 2026-08-06).

  • framer-motion: wrap the tree in <MotionConfig reducedMotion="user"> in src/providers.tsx — covers the PeekStrip slide/fade and every other motion.* use.
  • Map camera: in src/hooks/use-mapbox.ts (the centralized camera seam — FLY_CURVE/FLY_SPEED at :22-23, fitBounds :52-57, easeTo :79-90, flyTo :101-103), make flyTo/fitBounds/easeTo instant or near-instant under reduced motion (e.g. jumpTo/duration: 0/animate: false). One media-query check inside the hook; views stay untouched per .claude/rules/mapbox.md.
  • vaul drawers: an ADDITIVE @media (prefers-reduced-motion: reduce) block. src/styles/vaul.css is owned by a sibling CSS-scoping ticket — append-only, coordinate at merge. Alternative hook if cleaner: vaul honours [data-vaul-animate='false'].
  • Carousel autoplay is explicitly OUT of scope — a sibling swiper ticket owns ImageCarousel (WCAG 2.2.2 pause control lives there).

3. Focus & label polish

  • PeekStrip (src/views/DrawerStack/DrawerStack.tsx, PeekStrip component ~:107-165): the motion.button has no focus-visible style, and every strip shares the accessible name t('back') (passed at :516) — WCAG "duplicate accessible names". Add a visible focus ring (repo standard: focus-visible:ring-2 focus-visible:ring-focus) and a distinguishing per-strip name (e.g. "Back to "). Touch ONLY the PeekStrip component region of this file — a sibling perf ticket owns the imports section.
  • Chip close (src/components/atoms/Chip/Chip.tsx:18): the close slot is outline-none with only an opacity change on focus — no visible focus ring, unlike every other control (ActionRow, ToggleGroup, Checkbox, Slider all use focus-visible:ring-2 focus-visible:ring-focus). Align it.
  • Spinner SR text (src/components/atoms/Spinner/Spinner.tsx:72): <span className="sr-only">Loading</span> — the one untranslated screen-reader string. Localize it, but note Spinner renders in pre-i18n contexts (suspense fallbacks before i18next has loaded), so the fix must tolerate i18n not being ready and fall back to English rather than a raw key.
  • ContactPopover (src/components/molecules/EventActions/EventActions.tsx:43-55): the desktop contact popover renders a role="dialog" FloatingPortal with no FloatingFocusManager — unlike the Dropdown atom (src/components/atoms/Dropdown/Dropdown.tsx:140-157). Add focus management on the same pattern (initial focus in, focus return on close, Esc handled).
  • GeolocateControl (src/components/organisms/Mapbox/Map.tsx:380): the control's button label/tooltip is English-only. Investigate mapbox-gl's locale option (map-level locale prop / control strings) and wire it to the active locale; if mapbox-gl cannot localize it cleanly, document the outcome in the implementation report instead of forcing a hack.

New locale keys (Spinner label, per-strip back labels, GeolocateControl strings if wired) added across all 10 locales via pnpm i18n:add <dotted.key> '<{lng:value}>' [ns] — cs, de, en, es, fr, hu, nl, pt-BR, ru, uk.

Acceptance criteria

  • A failed submit is announced to assistive tech (role="alert"/live region) without per-keystroke over-announcement, and focus lands on the first invalid field
  • The fieldErrorId/aria-describedby contract is unchanged — all form atoms still resolve their described-by ids; existing tests stay green
  • With prefers-reduced-motion: reduce: framer-motion animations are reduced (MotionConfig), map camera moves are instant/near-instant, and vaul drawer transitions are suppressed via an additive media block (or data-vaul-animate='false')
  • Every PeekStrip has a visible focus indicator and a distinct accessible name
  • Chip's close button shows the standard focus-visible:ring-2 focus-visible:ring-focus treatment
  • Spinner SR text is localized with a safe English fallback when i18n is not ready
  • ContactPopover manages focus via FloatingFocusManager matching the Dropdown pattern
  • GeolocateControl is labelled in the active locale, or the investigation's blocker is documented in the implementation report
  • All new locale keys exist across all 10 locales (added via pnpm i18n:add)
  • Unit-lane tests where expressible (SSR-markup assertions per .claude/rules/tests.md) — e.g. FormField alert semantics, Chip focus classes, Spinner fallback text
  • pnpm lint && pnpm typecheck && pnpm test:run pass
  • Write an implementation report to .claude/reports/<issue-number>-<short-slug>.md — in the MAIN checkout at /Users/devindra/Documents/Projects/SahajAtlasWeb even when implementing from a worktree (the folder is gitignored) — covering what changed, what was deliberately NOT changed, and which readiness-report findings are resolved

Files affected

  • src/components/molecules/FormField/FormField.tsx
  • src/components/organisms/RegistrationForm/RegistrationForm.tsx — focus logic
  • src/providers.tsx — MotionConfig
  • src/hooks/use-mapbox.ts — reduced-motion camera behaviour
  • src/components/atoms/Chip/Chip.tsx
  • src/components/atoms/Spinner/Spinner.tsx
  • src/components/molecules/EventActions/EventActions.tsx
  • src/views/DrawerStack/DrawerStack.tsx — PeekStrip component region ONLY
  • src/styles/vaul.css — additive @media (prefers-reduced-motion: reduce) block only (file owned by a sibling ticket — append-only, coordinate at merge)
  • src/components/organisms/Mapbox/Map.tsx — the GeolocateControl line only (strictly additive locale wiring)
  • public/locales/<lng>/*.json — additive keys across all 10 locales

Parallel implementation: this ticket OWNS the files listed above (with the noted per-region limits); sibling release-hardening tickets run concurrently — avoid edits outside owned files except strictly additive ones (new locale keys, appended CSS blocks). Carousel autoplay/pause belongs to the sibling swiper ticket; the DrawerStack imports section belongs to the sibling perf ticket; vaul.css scoping belongs to the sibling CSS ticket.

References

  • .claude/reports/RELEASE_READINESS.md §5 (WCAG AA failures 3 & 4 + the should-fix list), Appendix C (rows: "Per-field errors not announced", "No prefers-reduced-motion anywhere", "PeekStrip focus + duplicate names; Chip focus ring", "Spinner SR text hard-coded English")
  • WCAG 2.2: 4.1.3 Status Messages, 3.3.1 Error Identification, 2.3.3 Animation from Interactions
  • Dropdown's FloatingFocusManager reference implementation: src/components/atoms/Dropdown/Dropdown.tsx:140-157
  • .claude/rules/tests.md (unit-lane SSR assertions), .claude/rules/mapbox.md (camera seam), .claude/rules/i18n-and-state.md (pnpm i18n:add)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Hold Until

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions