Repository navigation
fix(DateInput): a Reduce Motion step lands under its cross-fade, on the fade's own timeline - #9734
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| DateInput · Storybook | 103.4 kB (+105 B) · 15.3 kB CSS (0) | 3,788 (−10) | ✓ · ✓ · ✓ |
| TimeInput | 90.2 kB (+105 B) · 14.3 kB CSS (0) | — | — · — · — |
| PowerSearch | 184.9 kB (+98 B) · 20.6 kB CSS (0) | — | — · — · — |
2 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| DateTimeInput | 159.2 kB (+74 B) · 17.0 kB CSS (0) | — | — · — · — |
| lab/MobilePowerSearch | 214.7 kB (+60 B) · 1.2 kB CSS (0) | — | — · — · — |
Package size: @astryxdesign/core 6.11 MB packed (+1.6 kB); no new dependencies.
API changes: none in this pull request
Committed API report behind this build: core 50 rows; run pnpm api:report.
Touched components checked; add ci:run-visual, ci:run-a11y or ci:run-rtl to run the full suites.
Generated by PR Enrichment workflow | View full report
…he fade's own timeline Under Reduce Motion on a touch screen, a wheel step and a month step change under an opacity dip. The change landed on a timer at the dip's middle. A busy page could fire that timer after the dip had ended, and the rows moved fully visible. The dip is now its fade-out, then the change, then its fade-in: the fade-out holds at 0 until the change lands when it ends, on its own timeline. The wheel and the month scroller share it (playReducedMotionDip). The browser proof reads the frames the page draws until the column is at rest, not a fixed window of 45.
There was a problem hiding this comment.
Requesting changes: sequencing the landing on the fade-out's finished fixes the wheel, and in Chromium the hour rows now land fully faded even with a 300 ms main-thread stall right after the key. The month step needs one more change.
Blocking
- The month step still changes at full opacity on a busy page, because its
landonly callssetCenterRow(MonthScroller.tsx:501) and the scroll waits for React's next render whileplayReducedMotionDiphas already started the fade-in; with a 300 ms main-thread task right after the landing, the month moved fully visible in Chromium, and wrapping the update influshSync(() => setCenterRow(row))plus a unit case assertingscrollToruns before the fade-in exists fixes it. - The changeset, and the comments in
MonthScroller.tsxandreducedMotion.ts, say a month step never shows at full opacity on a busy page, which is only true once the first point is fixed.
It would also help to say in playReducedMotionDip's JSDoc that land must apply the change before it returns.
[Automated review]
| dipRef.current = playReducedMotionDip(scroller, fade, () => { | ||
| dipRef.current = null; | ||
| land(); | ||
| }); |
There was a problem hiding this comment.
This landing only schedules the scroll: for a step to another row, land calls setCenterRow(row) (line 501), and the scroll runs in the layout effect after React's next render, but playReducedMotionDip starts the fade-in as soon as land returns. With a 300 ms main-thread task right after the landing, the month moved fully visible in Chromium. Wrapping the update as flushSync(() => setCenterRow(row)) lands the scroll before the fade-in starts; a case that checks scrollTo runs while only the fade-out exists would cover it.
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [fix] Under Reduce Motion on a touch screen, a step on a DateInput, TimeInput or DateTimeInput wheel, and a month step in the touch calendar, change under their cross-fade even on a busy page. Before, the change landed on a timer at the fade's middle, and a busy page could fire it after the fade had ended, so the rows or the month moved fully visible. Now the change lands when the fade-out ends, on the fade's own timeline, and the fade-in starts only after it, so it never shows at full opacity. The month's dip now eases each half, as the wheels' does. |
There was a problem hiding this comment.
For the month step, "so it never shows at full opacity" holds only once the month's scroll lands before its fade-in starts (see the comment on MonthScroller.tsx).
27cda4e to
fb3b6e4
Compare
…starts The dip starts its fade-in as soon as the landing returns. A month step to another row only scheduled its scroll for React's next render, so a busy page could show the month change fully visible. Red here: the fade-in starts before the scroll.
… the fade-in The month scroller's landing sets the centre row, and the scroll lands in the layout effect of the render that follows. It now renders that update at once (flushSync), so the scroll lands before the dip starts its fade-in. playReducedMotionDip says that its landing must apply the change before it returns.
19cc4b3 to
34c13fd
Compare
There was a problem hiding this comment.
Requesting changes: landing the change on the fade-out's finished fixes the visible jump. In Chromium the wheel rows and the month now move at opacity 0 in every run, including with a 300 ms main-thread task after the input or after the fade-in starts, and the flushSync landing is covered by a test.
Blocking
- The dip now runs past the 200 ms cap in
design:reduced-motionDR2:playReducedMotionDipcreates the fade-in only afterland()returns (packages/core/src/motion/reducedMotion.ts:148-152), so it starts up to a frame after the fade-out ends, plus the month's synchronous render, and an idle month step's dip measured 200 to 250 ms in 9 of 9 runs where main's ended within 200 ms; starting the fade-in on the dip's own schedule (for example a negativedelayfor the time the landing ran late, capped so a long stall still fades in) and a case that lands a frame late would fix and cover it.
Non-blocking: the call-site comments at Wheel.tsx:399-400 and MonthScroller.tsx:509-511 repeat the helper's JSDoc and could go.
[Automated review]
| fadeIn = element.animate( | ||
| [{opacity: 0, easing: fade.easing}, {opacity: 1}], | ||
| {duration: half}, | ||
| ); |
There was a problem hiding this comment.
The fade-in is created only after land() returns, at the frame that notices the fade-out ended, so each dip grows by up to a frame plus the landing's work. In Chromium an idle month step (with its flushSync render) measured 200 to 250 ms in 9 of 9 runs, where main's single animation ended within 200 ms (design:reduced-motion DR2's cap). Starting the fade-in on the dip's own schedule keeps an on-time landing at 200 ms, for example delay: -late, where late is how far document.timeline.currentTime is past the fade-out's scheduled end, capped so a long stall still fades in.
| // its scroll lands, at its own dip's middle. It lands when the | ||
| // fade-out ends on the dip's own timeline, so a late frame cannot | ||
| // show the month changing at full opacity. |
There was a problem hiding this comment.
Non-blocking: this repeats playReducedMotionDip's JSDoc, and "at its own dip's middle" no longer matches when the month lands. It could go, or keep only "A newer step replaces this one: only its scroll lands."
| // The rows land when the fade-out ends on the dip's own timeline, so a | ||
| // late frame cannot show them moving at full opacity. |
There was a problem hiding this comment.
Non-blocking: this repeats playReducedMotionDip's JSDoc; it could go.
3740fc0 to
bbc55cb
Compare
The dip's fade-in starts only after the landing returns, and a new animation starts on the next frame. So every dip ran past its 200 ms. The fake animation now carries a start time, and the cases move the clock inside the landing. Red here: the fade-in takes no start from the fade-out's end.
The fade-in's start time is pinned to the fade-out's end, read against the clock after the landing, so an on-time dip stays at 200 ms and a late landing starts the fade-in partway in. After a long stall, half of the fade-in still plays, and the fade-in holds 0 until its start (fill: backwards). The wheel's and the month scroller's call sites no longer repeat the helper's note.
bbc55cb to
906818e
Compare
There was a problem hiding this comment.
Recommending approval. Pinning the fade-in's start to the fade-out's end keeps an on-time dip at exactly 200 ms, and in Chromium the wheel and month steps change while the column is faded, idle or with a 300 ms main-thread task during the fade-out.
Two new comments in playReducedMotionDip could be tighter; the inline suggestions are optional.
[Automated review]
| // The fade-in holds 0 until it starts: after a long stall, its start can | ||
| // come after the frame that runs this. |
There was a problem hiding this comment.
Non-blocking: the start lands after this frame only when the landing itself runs more than 50 ms; a stall before the frame gives a start before it, so the fade-in first draws partway in. Suggested wording:
// A landing that runs over 50 ms puts the fade-in's start after this frame.
// Until then the fade-in holds 0.| // The fade-in keeps the dip's own schedule: it starts where the fade-out | ||
| // ended, so the dip keeps its length. The clock is read after the | ||
| // landing, because a frame's timestamp does not count the landing's own | ||
| // work. After a long stall, half of the fade-in still plays. |
There was a problem hiding this comment.
Non-blocking: "The clock is read" is passive. Suggested wording:
// The fade-in starts where the fade-out ended, so the dip keeps its length.
// The clock reading comes after the landing, because a frame's timestamp
// does not include the landing's work. After a long stall, the fade-in's
// last half still plays.The dip now plays its fade-out and its fade-in as two animations, and the month changes between them. The browser case reads both halves: opacity 1 to 0, then 0 to 1, in at most 200 ms together.
There was a problem hiding this comment.
Recommending approval. Landing the change on the fade-out's own finished, with the fade-in's start pinned to the fade-out's end, keeps both Reduce Motion steps under their cross-fade: in Chromium and WebKit the hour wheel and the month change below full opacity even with a 300 ms main-thread task, and an idle dip still lasts 200 ms. The month spec's new two-halves assertion passes in both engines and fails against the previous behaviour, as it should.
One optional wording change: the comment at reducedMotion.ts:155-158 could use active voice, as the earlier inline suggestion there shows.
[Automated review]
User impact
With Reduce Motion on a touch screen, DateInput, TimeInput and DateTimeInput wheel steps and touch-calendar month steps change under an opacity dip. On a busy page the change could land after the dip ended, moving the rows or the month fully visible.
Problem and solution fit
Expected behavior and authority
design:reduced-motionDR2: under Reduce Motion on a coarse pointer, a change is an opacity-only cross-fade. No record changes.Smallest restoration
playReducedMotionDip(motion/reducedMotion.ts) plays the dip as its fade-out, the change, then its fade-in. The fade-out holds at 0 (fill: 'forwards') until its ownfinished; the change lands; the fade-in's start is pinned to the fade-out's end (a late landing starts it partway in, at most half), so the dip stays at 200 ms.cancel()stops both.flushSync), so its scroll lands before the fade-in.Evidence
flushSynccommit.Scope
Testing
Local gates at
a7ae1a2c0b(this head), six commits on main692aa26479: Prettier, core typecheck (0 errors), strict ESLint on the changed files (0),pnpm check:changesets; the three unit files 41 of 41. The browser runs, the full checklist and WebKit are running now.The main-thread hold came from a temporary seam that is not committed: a
keydownlistener that blocks the main thread for 300 ms in a task right after the key's handling.