CollapsibleBody's reduced-motion check is a one-time snapshot, not a live listener #85

Closed
opened 2026-09-12 01:51:34 -04:00 by jared · 0 comments
Owner

Severity: low · Type: a11y · Confidence: high

Location: src/app/components/message/MsgTypeRenderers.tsx:65-66

Problem

prefersReducedMotion is computed with a bare window.matchMedia('(prefers-reduced-motion: reduce)').matches read directly in the render body, with no change event listener and no re-render trigger. If the user toggles the OS-level reduced-motion setting while the app is open (common on macOS/Windows via a quick-settings toggle, or during a screen-recording/demo), the "Read more"/"Show less" max-height transition on long messages won't pick up the new preference until the whole component remounts (e.g. navigating away and back).

How to trigger

Open a room with a long, collapsed message; toggle "Reduce motion" in OS settings without reloading the tab; expand/collapse the message — the transition still animates (or still doesn't), reflecting the value read at first render.

Suggested fix

Use the existing useReducedMotion hook (src/app/hooks/useReducedMotion.ts, already used elsewhere in the Lotus codebase) instead of an inline matchMedia().matches snapshot, so this component reacts live like the rest of the app.


Filed from the September 2026 client audit (branch lotus @ 4bea4895).

**Severity:** low · **Type:** a11y · **Confidence:** high **Location:** `src/app/components/message/MsgTypeRenderers.tsx:65-66` ### Problem `prefersReducedMotion` is computed with a bare `window.matchMedia('(prefers-reduced-motion: reduce)').matches` read directly in the render body, with no `change` event listener and no re-render trigger. If the user toggles the OS-level reduced-motion setting while the app is open (common on macOS/Windows via a quick-settings toggle, or during a screen-recording/demo), the "Read more"/"Show less" `max-height` transition on long messages won't pick up the new preference until the whole component remounts (e.g. navigating away and back). ### How to trigger Open a room with a long, collapsed message; toggle "Reduce motion" in OS settings without reloading the tab; expand/collapse the message — the transition still animates (or still doesn't), reflecting the value read at first render. ### Suggested fix Use the existing `useReducedMotion` hook (`src/app/hooks/useReducedMotion.ts`, already used elsewhere in the Lotus codebase) instead of an inline `matchMedia().matches` snapshot, so this component reacts live like the rest of the app. --- _Filed from the September 2026 client audit (branch `lotus` @ 4bea4895)._
jared added this to the Audit 2026-09 · Medium & Low milestone 2026-09-12 01:51:34 -04:00
jared added the priority: lowa11yarea: messaging labels 2026-09-12 01:51:34 -04:00
jared self-assigned this 2026-09-12 01:51:34 -04:00
jared closed this issue 2026-09-12 20:29:02 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: LotusGuild/cinny#85