Repository navigation
fix(DateInput): a wheel's key step rests on the row it steps to - #10610
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 | 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
There was a problem hiding this comment.
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
useScrollSettlenow 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 ownsteeredRowRefwith its ownendSteerlisteners and arrival check (MonthScroller.tsxlines 393-400, 694-696 and 747-750), so please make the hook's steer the one tracker (aware of the axis, sinceMonthScrollerscrolls horizontally) and moveMonthScrolleronto 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 thesteerRefJSDoc in a header already past about 12 lines; one line is enough. - The comment at
useScrollSettle.tslines 165-166 restateswaitFrameandframesWaited; keep only the reason or remove it.
CI has not run on this head yet.
[Automated review]
91b7e86 to
fbafedd
Compare
There was a problem hiding this comment.
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
useScrollSettledetaches (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
keydownlistener (useScrollSettle.tsline 239) also ends the steer on Tab, so ArrowDown then Tab on a stalled page still turns the wheel back. Wheel.tsxline 292:MAX_RE_AIMSis 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}); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Agreed, and kept for a follow-up: the same rule ends MonthScroller's steers, so narrowing the keys changes it too.
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.
fbafedd to
7a98ea6
Compare
There was a problem hiding this comment.
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]
There was a problem hiding this comment.
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]
|
/approve-spec 95c2cb3 |
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
scrollend, or after 220 ms with no scroll event. A key step's scroll is the wheel's own smoothscrollTo. 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.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:DateInputFR14: "a keyboard or assistive-technology activation commits at once". The step commits its row and keeps it. UIKit'sselectRow(_:inComponent:animated:)andsetDate(_: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
useScrollSettleowns 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.MonthScrollerkept 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.ScrollWheelstarts 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"".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
scrollendrests 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:Each of these four then lets the browser land the re-aim, and checks that the column rests on the committed row (
scrollTopwithin 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:"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.tsxadds 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
Testing
pnpm -F @astryxdesign/core typecheck0;CI=true pnpm lint0 errors; Prettier clean;check:changesets0;check:knowledge0; the DateInput, DateTimeInput, TimeInput and Calendar unit tests: 1,478 passed.--cpus=2,LP_NUM_THREADS=2, 4 workers): the mouse case ×20 passed.core-dateinput--bottom-sheet-narrow-range, logging the finalscrollTopagainst 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,MonthScrollerandMonthScrollerStepsinteraction specs: Chromium 21 passed, 2 skipped; WebKit (--cpus=4,LP_NUM_THREADS=4) 17 passed, 6 skipped.