Skip to content

fix(DateInput): a wheel's key step rests on the row it steps to - #10610

Merged
cixzhang merged 2 commits into
meta:mainfrom
vjeux:uikit/wheel-step-rests-on-its-row
Nov 9, 2026
Merged

cixzhang merged 2 commits into
meta:mainfrom
vjeux:uikit/wheel-step-rests-on-its-row

Conversation

@vjeux

@vjeux vjeux commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

User impact

With a mouse or trackpad, the date and time sheets show their wheels as scrolling columns. An arrow key on a focused wheel steps it one row: the new row commits at once, and the column scrolls there. On a busy page or a slow device, the wheel could then turn back to the row it was leaving and commit that row instead. In the DateInput sheet's month wheel, ArrowDown from March showed April, then went back to March and stayed there.

Problem and solution fit

  • Why does the wheel turn back? The scrolling column commits the row under its band when the scroller comes to rest: on scrollend, or after 220 ms with no scroll event. A key step's scroll is the wheel's own smooth scrollTo. When the page draws no frame of it for longer than 220 ms, the quiet period ends mid-step. WebKit can also end a scroll part-way when a second step retargets it. Either way the settle read the row the step was leaving and committed it. After that render, the wheel turned back onto that row.
  • Why does it harm the task? The key press seems to do nothing, or the month moves back, and the person presses again.
  • Why does it matter? A stall of a few hundred milliseconds is common on a loaded device, and the step it hits is lost without a sign.

The month calendar's scroller already solves this for its own scrolls: it tracks each scroll it starts as a steer, and a rest before the steer arrives finishes that scroll instead of rounding it back. The wheel now does the same. A step commits its row at once, so a rest short of that row only finishes the scroll and commits nothing. A scroll a person makes still rests where it stops.

Expected behavior and authority

component:DateInput FR14: "a keyboard or assistive-technology activation commits at once". The step commits its row and keeps it. UIKit's selectRow(_:inComponent:animated:) and setDate(_:animated:) set the value at once, and the animation never changes it. No record states the rest signal itself (FR13 and DEC-1 say "comes to rest"), so no record changes.

Smallest restoration

  • useScrollSettle owns the steer for both of its callers: useScrollSteer() holds the row the caller's own scroll heads for, and the hook ends it on a person's input (a touch, a wheel or trackpad, a pointer press, a key) and when the settle detaches. MonthScroller kept that tracker itself. It now uses the hook's, with the same reads, writes and arrivals, so its behavior does not change: its settle detaches only when it unmounts. A wheel's settle detaches when the wheel hides, so a steer whose scroll never came to rest (a click on the row already under the band, a step just before the wheels close) cannot pull the wheel back to an old row when it is shown again.
  • ScrollWheel starts the steer for each scroll it makes (a step, a row tap, a turn onto an outside value, the travel from a disabled row). In its settle, a steer short of its row re-aims the scroll at that row and commits nothing. A rest on the row ends the steer, and the settle commits as before. The re-aim is bounded: at most three times, and only while the column has moved since the last one. A rest short of the row with no progress ends the steer, and the settle commits the row the column shows, so the row shown and the value always agree.

No public API, visual or default changes.

Evidence

  • Reproduction before the change:

    • MonthYearWheels.interaction.browser.spec.ts "with a mouse › the scrolling month wheel moves only the calendar, not the date", WebKit, two CPUs (--cpus=2, one physical core), 4 workers, ×20 on main 1c8292c: 2 failed bare, "Expected: "April", Received: "March"".
    • In Chromium, a 300 ms page-side hold on the step's first frame, ×12 on main: the wheel ended on March 5 times. The hold can't be deterministic: after it, Chromium runs either the overdue timer or the next frame first.
  • Result after the change: on the same WebKit run, 20 of 20 passed; with the Chromium hold, the wheel ended on April 12 of 12 times.

  • Representative unchanged path: a trackpad or a finger that takes the wheel mid-step still rests where it stops. A step on a browser without scrollend rests a quiet period after the frame that reaches its row. The month calendar's existing settle tests pass unchanged, among them "finishes a steer the browser cut short instead of rounding it back".

  • Regression test or other mutation-sensitive proof: Wheel.test.tsx "Wheel — a key step on a page starved of frames". The first four cases fail on main, which commits the row the step is leaving:

    • "rests on the row a key steps to when its frames stop for longer than the quiet period"
    • "keeps the row a key steps to when the quiet period of a scroll before the key ends first"
    • "finishes a key step that stops short of its row instead of rounding it back, without scrollend"
    • "finishes a second key step that the browser ends part-way instead of rounding it back"

    Each of these four then lets the browser land the re-aim, and checks that the column rests on the committed row (scrollTop within 0.5 px of its offset). "commits the row the column shows when a key step rests short of its row again, with no progress" fails on main too: the step snaps back onto its old row twice, the wheel re-aims once, then commits that row with the column on it. Three guards pass on main and here:

    • "rests on the row a key steps to a quiet period after the frame that reaches it, without scrollend"
    • "commits the row a trackpad leaves it on when it takes the wheel during a key step"
    • "commits the row a finger leaves it on when it takes the wheel during a key step"

    "parks on the value it is shown with after a hide, though a scroll of its own never moved" checks the hide path: a click on the row already under the band, the wheel hidden, its value changed and the wheel shown again. It parks on the new value and commits nothing, as on main.

    MonthScrollerSettle.test.tsx adds three cases that hold the month calendar to its behavior on the shared steer: "rests a step that arrives on scrollend once: no correction and no report, and a scroll after it reports", "keeps a steer through a render: the settle still finishes it" and "ends a steer on a person’s input, so the settle rounds their scroll to the nearest month".

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

  • At this head: pnpm -F @astryxdesign/core typecheck 0; CI=true pnpm lint 0 errors; Prettier clean; check:changesets 0; check:knowledge 0; the DateInput, DateTimeInput, TimeInput and Calendar unit tests: 1,478 passed.
  • Browser runs used Storybook built at this head:
    • The hide path, with a mouse in the narrow-range sheet: open the wheels on March, click March, close them, press Next month, and open them again. Main and this head stay on April (Chromium 4 of 4, WebKit 3 of 3). The previous head of this pull request, fbafedd, went back to March in every run.
    • WebKit (--cpus=2, LP_NUM_THREADS=2, 4 workers): the mouse case ×20 passed.
    • The ArrowDown step on core-dateinput--bottom-sheet-narrow-range, logging the final scrollTop against the committed month's row offset: Chromium ×12 with no hold and ×12 with a 300 ms hold on the step's first frame. Every run ended on April, with the column exactly on April's row.
    • MonthYearWheels, Wheel, WheelActivation, MonthScroller and MonthScrollerSteps interaction specs: Chromium 21 passed, 2 skipped; WebKit (--cpus=4, LP_NUM_THREADS=4) 17 passed, 6 skipped.

@vercel

vercel Bot commented Nov 8, 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 8, 2026 12:20pm UTC

Request Review

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

astracat-bot Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

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

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 95c2cb3

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
DateInput · Storybook 182.9 kB (+207 B) · 16.8 kB CSS (0) 5,752 (+51) ✓ · ✓ · ✓
TimeInput 158.6 kB (+201 B) · 15.8 kB CSS (0) — — · — · —
DateTimeInput 204.7 kB (+161 B) · 18.5 kB CSS (0) — — · — · —
1 more component
Component Size LoC Visual · A11y · RTL
PowerSearch 282.6 kB (+153 B) · 23.6 kB CSS (0) — — · — · —

Package size: @astryxdesign/core 7.00 MB packed (+1.5 kB); no new dependencies.

API changes: none in this pull request

Committed API report behind this build: cli 29 rows, core 35 rows, theme-butter 1 row, theme-y2k 1 row; 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

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

Changes requested. The fix keeps a wheel's key step on its row through a frame stall (the new stall tests show it), but it adds a second steer tracker beside one that already exists.

Blocking

  • useScrollSettle now tracks where the caller's own scroll goes and ends that on a touch, wheel or pointer press, while its other caller, MonthScroller, keeps its own steeredRowRef with its own endSteer listeners and arrival check (MonthScroller.tsx lines 393-400, 694-696 and 747-750), so please make the hook's steer the one tracker (aware of the axis, since MonthScroller scrolls horizontally) and move MonthScroller onto it, or explain in the description why the hook cannot serve it.

Non-blocking

  • The new header section in useScrollSettle.ts (lines 55-71) repeats the steerRef JSDoc in a header already past about 12 lines; one line is enough.
  • The comment at useScrollSettle.ts lines 165-166 restates waitFrame and framesWaited; keep only the reason or remove it.

CI has not run on this head yet.

[Automated review]

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

Changes requested. Moving the steer into useScrollSettle resolves the earlier shared-path request, and the new stall tests show that a key step now keeps its row, but the steer can outlive a hidden wheel.

Blocking

  • In the DateInput sheet, a steer whose scroll never comes to rest (a click on the month already under the band, Home or End on the end row, or a step followed by closing the wheels) stays set while the wheels are closed, so after the calendar moves to another month, reopening the wheels re-aims at the old row and commits it, which moves the calendar back against DateInput FR23 ("Opening the wheels changes nothing"); please end the steer when useScrollSettle detaches (its cleanup at line 241) and add a regression test that hides the wheel, changes its value and shows it again.

To reproduce in the narrow-range bottom-sheet story with a mouse: open the wheels on March, click March, close them, press Next month, and reopen them; the title goes back to March 2026.

Non-blocking

  • The keydown listener (useScrollSettle.ts line 239) also ends the steer on Tab, so ArrowDown then Tab on a stalled page still turns the wheel back.
  • Wheel.tsx line 292: MAX_RE_AIMS is a cap, not a rate, and the comment can say so.

[Automated review]

element.addEventListener('touchstart', endSteer, {passive: true});
element.addEventListener('wheel', endSteer, {passive: true});
element.addEventListener('pointerdown', endSteer, {passive: true});
element.addEventListener('keydown', endSteer, {passive: true});

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 ends the steer for every key, Tab included. After ArrowDown then Tab with no frame for 300 ms, the wheel commits 11 and then 10, as on main. Ending it only for keys that scroll the column natively, or leaving keys to the wheel's own handler (which restarts the steer), would keep the fix through a Tab.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, and kept for a follow-up: the same rule ends MonthScroller's steers, so narrowing the keys changes it too.

Comment thread packages/core/src/DateInput/Wheel.tsx Resolved
With a mouse or trackpad, the sheet's scrolling wheel commits the row
under its band when the scroller comes to rest: on `scrollend`, or
after a quiet period of 220 ms with no scroll event. A key step
commits its row at once and then scrolls there with a smooth
`scrollTo`. On a busy page or a slow device the scroll can draw no
frame for longer than the quiet period, and WebKit can end a scroll
that a second step retargeted part-way. The settle then read the row
the step was leaving and committed it, and the wheel turned back.

MonthScroller already tracks its own scroll as a steer, and its settle
finishes a steer the browser cut short instead of rounding it back.
That steer moves into useScrollSettle as useScrollSteer, one tracker
for both callers: the caller starts it before each scroll it makes and
ends it when the scroll arrives, and a finger, a wheel or trackpad, a
press or a key on the scroller ends it in the hook. MonthScroller
keeps its behavior. The steer also ends when the settle detaches, so a
steer whose scroll never came to rest (a click on the row already
under the band, or a step just before the wheels close) cannot pull a
wheel shown again back to an old row. MonthScroller's settle never
detaches while it is mounted.

The wheel now steers each scroll it starts, and a rest short of the
steered row re-aims at it and commits nothing: the step committed its
row already. A rest on the row ends the steer. The
re-aim is bounded: at most three, and only while the column moved
since the last one. A rest with no progress ends the steer, and the
settle commits the row the column shows, so the two always agree.

Wheel.test.tsx: a step whose frames stop for longer than the quiet
period, a quiet period from an earlier scroll that ends before the
step's first frame, a step that stops short of its row, and a second
step that the browser ends part-way. All four commit the old row on
main; here each re-aims exactly once and lands on its committed row,
scrollTop included. A step
whose re-aim snaps back again commits the row shown. A step that
reaches its row rests without `scrollend`; a wheel hidden after a
scroll that never moved, its value changed and shown again, parks on
the new value; and a
trackpad or a finger that takes over mid-step still rests where it
stops. MonthScrollerSettle.test.tsx: a step that arrives rests once on
`scrollend` with no correction and no report, a steer survives a
render, and a person's input ends a steer, so the settle rounds their
scroll.

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

Approved pending CI. CI has not run on this head yet: it starts once the pull request is marked ready for review and a maintainer adds the ci:run label, because the branch lives in a fork.

The scrolling wheel now keeps the row a key step commits through a stalled or cut-short scroll, as the DateInput record's FR14 and FR17 require: the five new stall cases fail on main and pass here, and hiding the wheels now drops a steer that never came to rest, so reopening them no longer turns the month back.

  • Non-blocking: a key that does not scroll the wheel, such as Tab, still ends the steer, so ArrowDown then Tab on a stalled page commits the old row, as on main; the follow-up you mentioned would cover it.

[Automated review]

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 8, 2026
@vjeux
vjeux marked this pull request as ready for review November 8, 2026 04:08

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

Approved. CI passes on this head.

The sheet wheel now keeps the row a key step commits through a stalled or cut-short scroll, as the DateInput record's FR14 and FR17 require: the five stall cases fail without the fix and pass here. This update only merges main, and the change itself is as it was.

  • Non-blocking, as noted before: every key, Tab included, still ends the steer, so ArrowDown then Tab on a stalled page turns back as it does on main; fine as the follow-up you planned.

[Automated review]

@cixzhang

cixzhang commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 95c2cb3

@cixzhang
cixzhang merged commit 7cc9340 into meta:main Nov 9, 2026
78 checks passed
@vjeux
vjeux deleted the uikit/wheel-step-rests-on-its-row branch November 9, 2026 06:41

This branch was successfully deployed

1 active deployment
Preview — 95c2cb38 Deployed Nov 8, 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