Skip to content

Map: honour prefers-reduced-motion for flyTo and zoom animations - #305

Merged
yakew7 merged 1 commit into
StudentSuite:mainfrom
jay23606:pr-go/297-map-ignores-prefers-reduced-motion-flyto
Oct 23, 2026
Merged

yakew7 merged 1 commit into
StudentSuite:mainfrom
jay23606:pr-go/297-map-ignores-prefers-reduced-motion-flyto

Conversation

@jay23606

Copy link
Copy Markdown
Contributor

Problem

Clicking a cluster, locating yourself, selecting a pin or choosing a city all called Leaflet's animated flyTo / flyToBounds, and the map's zoom, fade and marker-zoom animations were always on. Visitors with prefers-reduced-motion: reduce still got long animated pans and zooms, which can trigger vestibular symptoms. Only the hero particles honoured the setting.

Change

  • map-view.tsx: a small prefersReducedMotion() helper (guarded for SSR and environments without matchMedia).
  • The five flyTo / flyToBounds calls (cluster click, cluster keydown, FlyToUser, FlyToPlace, FlyToBounds) pass animate: !prefersReducedMotion(), read at call time.
  • MapContainer gets zoomAnimation, fadeAnimation and markerZoomAnimation set from the same check.

With the setting off, the options are animate: true, which is Leaflet's default, so the animations are unchanged.

Testing

  • Added one regression test in src/components/map/map-view.test.tsx: it stubs matchMedia to match (prefers-reduced-motion: reduce) and asserts flyTo receives animate: false. It fails on the base code with expected "vi.fn()" to be called with arguments and passes with the change.
  • npm run test:unit passes (580 tests).
  • npm run lint and npx tsc --noEmit pass.
  • Prettier passes for the two changed files (npx prettier --check --end-of-line crlf ...).

Not verified in a browser with devtools emulation; the unit test covers the call options only.

Refs #297

Regression test: fails on base twice (/to be called with arguments/), passes on fix twice (npx vitest run src/components/map/map-view.test.tsx -t "prefers-reduced-motion")

Fixes #297

@jay23606

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@vercel

vercel Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

@jay23606 is attempting to deploy a commit to the studentsuite Team on Vercel.

A member of the Team first needs to authorize it.

@yakew7
yakew7 merged commit e7b5e11 into StudentSuite:main Oct 23, 2026
4 of 5 checks passed
@jay23606
jay23606 deleted the pr-go/297-map-ignores-prefers-reduced-motion-flyto branch October 23, 2026 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Map ignores prefers-reduced-motion: flyTo animates for everyone

2 participants