Skip to content

fix(DateInput): a Reduce Motion step lands under its cross-fade, on the fade's own timeline - #9734

Merged
cixzhang merged 6 commits into
meta:mainfrom
vjeux:uikit/c21-reduce-motion-dip
Nov 3, 2026
Merged

cixzhang merged 6 commits into
meta:mainfrom
vjeux:uikit/c21-reduce-motion-dip

Conversation

@vjeux

@vjeux vjeux commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Why? The dip played as one animation, and the change landed on a timer at its middle. A busy page fires that timer late, after the dip.
  • Why does it harm? The rows move fully visible instead of fading.
  • Why this fix? The change lands on the dip's own timeline, so no delay can put it outside the dip.

Expected behavior and authority

design:reduced-motion DR2: 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 own finished; 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.
  • The wheel and the month scroller use it instead of the timer, keeping their other rules. The month's landing renders at once (flushSync), so its scroll lands before the fade-in.
  • One visible change: the month's dip, eased once over the whole dip before, now eases each half, as the wheels' does: it slows into invisible and out again, with the same length and middle.

Evidence

  • Reproduction before the change: main's wheel with the main thread held 300 ms right after the arrow key: the rows land at opacity 1, 5 of 5; WheelRest's proof on main fails 1 run in 40 pinned to two threads.
  • Result after the change: running at this head against a Storybook built from it: the same hold, the 2-thread pin at 4 workers ×10, and the gates below.
  • Representative unchanged path: with no hold, both pass; a mouse, a fine-pointer keyboard and a trackpad still land at once.
  • Regression test: the "however late its frame comes" cases advance timers 10 s and see no landing; with 7 others they fail against main's components. "lands a step to another month before its fade-in starts" checks fade-out, scroll, fade-in; red before the flushSync commit.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

pnpm exec vitest run --project ui packages/core/src/motion/reducedMotion.test.ts packages/core/src/DateInput/Wheel.test.tsx packages/core/src/DateInput/MonthScroller.test.tsx
pnpm exec playwright test --config playwright.config.ts --project=chromium packages/core/src/DateInput/__tests__/WheelRest.a11y.chromium.spec.ts

Local gates at a7ae1a2c0b (this head), six commits on main 692aa26479: 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 keydown listener that blocks the main thread for 300 ms in a task right after the key's handling.

@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 3, 2026 12:25pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 3, 2026, 12:37 PM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · a7ae1a2

Storybook · Sandbox · built from this PR's head

Modified components

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.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 land only calls setCenterRow (MonthScroller.tsx:501) and the scroll waits for React's next render while playReducedMotionDip has 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 in flushSync(() => setCenterRow(row)) plus a unit case asserting scrollTo runs before the fade-in exists fixes it.
  • The changeset, and the comments in MonthScroller.tsx and reducedMotion.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]

Comment on lines +511 to +514
dipRef.current = playReducedMotionDip(scroller, fade, () => {
dipRef.current = null;
land();
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

vjeux added 2 commits November 3, 2026 02:52
…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.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-motion DR2: playReducedMotionDip creates the fade-in only after land() 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 negative delay for 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]

Comment on lines +149 to +152
fadeIn = element.animate(
[{opacity: 0, easing: fade.easing}, {opacity: 1}],
{duration: half},
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +509 to +511
// 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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."

Comment thread packages/core/src/DateInput/Wheel.tsx Outdated
Comment on lines +399 to +400
// 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: this repeats playReducedMotionDip's JSDoc; it could go.

vjeux added 2 commits November 3, 2026 03:36
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.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]

Comment on lines +149 to +150
// The fade-in holds 0 until it starts: after a long stall, its start can
// come after the frame that runs this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +155 to +158
// 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]

@vjeux
vjeux marked this pull request as ready for review November 3, 2026 12:48
@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 3, 2026
@cixzhang
cixzhang marked this pull request as draft November 3, 2026 12:51
@cixzhang
cixzhang marked this pull request as ready for review November 3, 2026 12:52
@cixzhang
cixzhang merged commit 273ec43 into meta:main Nov 3, 2026
151 of 156 checks passed
@vjeux
vjeux deleted the uikit/c21-reduce-motion-dip branch November 3, 2026 13:28

This branch was successfully deployed

1 active deployment
Preview — a7ae1a2c Deployed Nov 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants