Repository navigation
fix(core): a press inside a scroll view highlights 150 ms after touch - #10260
Conversation
Inside a scroll view, a pressable waits the content-touch delay before its highlight. The press controller and PressTracker started that wait when their code ran, so a busy page that handled the touch late made the highlight late by the same time. In the iOS 26.2 Simulator the listener ran 8 to 52 ms after the touch, and the highlight came 159 to 213 ms after it. It now comes 151 to 158 ms after the touch. The wait now counts from the touch's own time: an event's timeStamp, or a gesture touch's time. A time off the page's clock counts as now. This affects every pressable in a scroll view, and SegmentedControl, Switch, Slider and usePressTracker controls there.
|
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 |
|---|---|---|---|
| Button · Storybook | 56.5 kB (+175 B) · 9.8 kB CSS (0) | 688 (0) | ✓ · ✓ · ✗ |
| NumberInput | 67.9 kB (+198 B) · 11.2 kB CSS (0) | — | — · — · — |
| Switch | 97.2 kB (+197 B) · 9.9 kB CSS (0) | — | — · — · — |
111 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| DateRangeInput | 87.8 kB (+188 B) · 12.3 kB CSS (0) | — | — · — · — |
| lab/ChatReactionBar | 99.8 kB (+187 B) · 1.1 kB CSS (0) | — | — · — · — |
| lab/Schedule | 100.7 kB (+182 B) · 3.9 kB CSS (0) | — | — · — · — |
| Step | 30.0 kB (+178 B) · 5.6 kB CSS (0) | — | — · — · — |
| Typeahead | 75.2 kB (+178 B) · 12.3 kB CSS (0) | — | — · — · — |
| lab/ListInput | 97.3 kB (+177 B) · 1.6 kB CSS (0) | — | — · — · — |
| ChatComposerInput | 71.0 kB (+176 B) · 11.1 kB CSS (0) | — | — · — · — |
| MultiSelector | 90.3 kB (+176 B) · 16.5 kB CSS (0) | — | — · — · — |
| ContextMenuItem | 27.2 kB (+175 B) · 6.3 kB CSS (0) | — | — · — · — |
| Slider | 102.6 kB (+175 B) · 8.7 kB CSS (0) | — | — · — · — |
| lab/TransferList | 91.9 kB (+175 B) · 1.7 kB CSS (0) | — | — · — · — |
| ChatComposerTokenElement | 71.0 kB (+174 B) · 11.1 kB CSS (0) | — | — · — · — |
| IconButton | 56.5 kB (+173 B) · 9.8 kB CSS (0) | — | — · — · — |
| DateTimeInput | 200.4 kB (+172 B) · 18.3 kB CSS (0) | — | — · — · — |
| ChatSendButton | 56.9 kB (+171 B) · 9.8 kB CSS (0) | — | — · — · — |
| TableSelectionToolbar | 66.0 kB (+171 B) · 13.0 kB CSS (0) | — | — · — · — |
| lab/CommentComposer | 140.3 kB (+171 B) · 1.9 kB CSS (0) | — | — · — · — |
| MobileNavToggle | 56.8 kB (+170 B) · 9.8 kB CSS (0) | — | — · — · — |
| lab/TransferListSelector | 98.9 kB (+170 B) · 1.9 kB CSS (0) | — | — · — · — |
| DialogHeader | 59.2 kB (+168 B) · 11.4 kB CSS (0) | — | — · — · — |
| SelectableCard | 17.1 kB (+168 B) · 7.3 kB CSS (0) | — | — · — · — |
| TopNavItem | 12.8 kB (+168 B) · 4.0 kB CSS (0) | — | — · — · — |
| lab/ChatEmojiPicker | 98.7 kB (+168 B) · 773 B CSS (0) | — | — · — · — |
| Lightbox | 107.6 kB (+167 B) · 10.3 kB CSS (0) | — | — · — · — |
| TopNavMegaMenu | 65.6 kB (+167 B) · 11.7 kB CSS (0) | — | — · — · — |
| TopNavMegaMenuItem | 12.9 kB (+167 B) · 4.2 kB CSS (0) | — | — · — · — |
| TreeList | 42.8 kB (+167 B) · 5.6 kB CSS (0) | — | — · — · — |
| ChatLayout | 59.7 kB (+166 B) · 10.4 kB CSS (0) | — | — · — · — |
| CodeBlock | 71.1 kB (+166 B) · 11.1 kB CSS (0) | — | — · — · — |
| lab/DiffViewer | 82.8 kB (+166 B) · 2.1 kB CSS (0) | — | — · — · — |
| ChatComposer | 73.0 kB (+165 B) · 11.7 kB CSS (0) | — | — · — · — |
| ChatDictationButton | 57.0 kB (+165 B) · 9.9 kB CSS (0) | — | — · — · — |
| ChatLayoutScrollButton | 57.0 kB (+165 B) · 10.0 kB CSS (0) | — | — · — · — |
| SideNavCollapseButton | 57.3 kB (+165 B) · 9.9 kB CSS (0) | — | — · — · — |
| ToggleButton | 57.3 kB (+165 B) · 9.9 kB CSS (0) | — | — · — · — |
| Banner | 58.5 kB (+163 B) · 10.4 kB CSS (0) | — | — · — · — |
| CommandPaletteItem | 12.1 kB (+163 B) · 3.6 kB CSS (0) | — | — · — · — |
| ListItem | 65.7 kB (+162 B) · 11.1 kB CSS (0) | — | — · — · — |
| MobileNav | 66.2 kB (+162 B) · 10.5 kB CSS (0) | — | — · — · — |
| DrawerHeader | 59.4 kB (+161 B) · 12.8 kB CSS (0) | — | — · — · — |
| CheckboxListItem | 66.7 kB (+160 B) · 11.1 kB CSS (0) | — | — · — · — |
| DateInput | 178.0 kB (+160 B) · 16.6 kB CSS (0) | — | — · — · — |
| Popover | 84.2 kB (+160 B) · 13.9 kB CSS (0) | — | — · — · — |
| AvatarGroupOverflow | 45.2 kB (+159 B) · 5.5 kB CSS (0) | — | — · — · — |
| SelectorOption | 19.8 kB (+158 B) · 6.0 kB CSS (0) | — | — · — · — |
| Stepper | 58.1 kB (+158 B) · 10.0 kB CSS (0) | — | — · — · — |
| TimeInput | 154.7 kB (+158 B) · 15.7 kB CSS (0) | — | — · — · — |
| AppShell | 86.4 kB (+157 B) · 13.3 kB CSS (0) | — | — · — · — |
| Calendar | 67.4 kB (+157 B) · 10.4 kB CSS (0) | — | — · — · — |
| Link | 49.4 kB (+157 B) · 7.0 kB CSS (0) | — | — · — · — |
| RadioListItem | 63.5 kB (+157 B) · 10.0 kB CSS (0) | — | — · — · — |
| Token | 27.5 kB (+157 B) · 4.7 kB CSS (0) | — | — · — · — |
| CheckboxInput | 60.5 kB (+156 B) · 9.1 kB CSS (0) | — | — · — · — |
| Item | 16.4 kB (+156 B) · 5.5 kB CSS (0) | — | — · — · — |
| Outline | 23.9 kB (+156 B) · 4.1 kB CSS (0) | — | — · — · — |
| lab/TourStep | 90.5 kB (+156 B) · 590 B CSS (0) | — | — · — · — |
| AlertDialog | 100.4 kB (+155 B) · 14.2 kB CSS (0) | — | — · — · — |
| ClickableCard | 16.9 kB (+155 B) · 7.1 kB CSS (0) | — | — · — · — |
| CommandPalette | 67.4 kB (+155 B) · 12.4 kB CSS (0) | — | — · — · — |
| DropdownMenuItem | 20.8 kB (+155 B) · 6.2 kB CSS (0) | — | — · — · — |
| FileInput | 65.3 kB (+155 B) · 10.8 kB CSS (0) | — | — · — · — |
| lab/CommentPin | 53.4 kB (+154 B) · 1.2 kB CSS (0) | — | — · — · — |
| lab/CommentThread | 303.6 kB (+154 B) · 2.4 kB CSS (0) | — | — · — · — |
| Collapsible | 26.3 kB (+153 B) · 4.5 kB CSS (0) | — | — · — · — |
| lab/SelectableCardGroup | 60.4 kB (+153 B) · 162 B CSS (0) | — | — · — · — |
| BaseTypeahead | 66.7 kB (+152 B) · 10.8 kB CSS (0) | — | — · — · — |
| TopNav | 67.9 kB (+152 B) · 10.8 kB CSS (0) | — | — · — · — |
| richtext/RichTextView | 272.1 kB (+152 B) · 2.3 kB CSS (0) | — | — · — · — |
| DropdownMenuRadioItem | 21.6 kB (+151 B) · 6.6 kB CSS (0) | — | — · — · — |
| TextInput | 63.9 kB (+151 B) · 11.0 kB CSS (0) | — | — · — · — |
| ComplexSelector | 66.8 kB (+150 B) · 11.6 kB CSS (0) | — | — · — · — |
| Tab | 13.5 kB (+150 B) · 4.2 kB CSS (0) | — | — · — · — |
| SegmentedControlItem | 16.4 kB (+149 B) · 4.3 kB CSS (0) | — | — · — · — |
| SideNav | 85.8 kB (+149 B) · 11.2 kB CSS (0) | — | — · — · — |
| lab/EmojiPicker | 82.3 kB (+149 B) · 751 B CSS (0) | — | — · — · — |
| SideNavItem | 66.3 kB (+147 B) · 10.9 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditor | 292.5 kB (+146 B) · 2.6 kB CSS (0) | — | — · — · — |
| Tokenizer | 86.6 kB (+144 B) · 18.2 kB CSS (0) | — | — · — · — |
| DropdownMenuCheckboxItem | 21.6 kB (+143 B) · 6.6 kB CSS (0) | — | — · — · — |
| Thumbnail | 60.8 kB (+143 B) · 11.4 kB CSS (0) | — | — · — · — |
| Carousel | 65.3 kB (+142 B) · 10.8 kB CSS (0) | — | — · — · — |
| Toast | 94.0 kB (+135 B) · 10.1 kB CSS (0) | — | — · — · — |
| Markdown | 163.9 kB (+127 B) · 19.8 kB CSS (0) | — | — · — · — |
| TabMenu | 67.6 kB (+125 B) · 11.0 kB CSS (0) | — | — · — · — |
| TopNavMenu | 70.5 kB (+123 B) · 11.1 kB CSS (0) | — | — · — · — |
| lab/Comments | 308.8 kB (+119 B) · 2.5 kB CSS (0) | — | — · — · — |
| BreadcrumbItem | 80.5 kB (+115 B) · 12.0 kB CSS (0) | — | — · — · — |
| ContextMenu | 91.8 kB (+113 B) · 16.8 kB CSS (0) | — | — · — · — |
| Pagination | 105.0 kB (+112 B) · 17.4 kB CSS (0) | — | — · — · — |
| Selector | 95.0 kB (+112 B) · 17.1 kB CSS (0) | — | — · — · — |
| TopNavHeading | 70.8 kB (+112 B) · 10.9 kB CSS (0) | — | — · — · — |
| SideNavHeading | 71.3 kB (+110 B) · 11.1 kB CSS (0) | — | — · — · — |
| SegmentedControl | 90.3 kB (+107 B) · 6.8 kB CSS (0) | — | — · — · — |
| Table | 101.2 kB (+107 B) · 17.5 kB CSS (0) | — | — · — · — |
| PowerSearch | 277.5 kB (+104 B) · 23.3 kB CSS (0) | — | — · — · — |
| TableHeaderCell | 92.6 kB (+103 B) · 17.0 kB CSS (0) | — | — · — · — |
| DropdownMenu | 91.8 kB (+92 B) · 17.0 kB CSS (0) | — | — · — · — |
| TableCell | 93.0 kB (+92 B) · 17.3 kB CSS (0) | — | — · — · — |
| MoreMenu | 92.1 kB (+80 B) · 17.0 kB CSS (0) | — | — · — · — |
| DropdownMenuSubMenu | 65.4 kB (+78 B) · 9.6 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditorToolbar | 246.3 kB (+71 B) · 454 B CSS (0) | — | — · — · — |
| NavHeadingMenu | 15.6 kB (+39 B) · 3.5 kB CSS (0) | — | — · — · — |
| InputGroup | 52.6 kB (+37 B) · 7.8 kB CSS (0) | — | — · — · — |
| Field | 51.0 kB (+35 B) · 7.2 kB CSS (0) | — | — · — · — |
| RadioList | 52.4 kB (+34 B) · 7.2 kB CSS (0) | — | — · — · — |
| CheckboxList | 54.8 kB (+33 B) · 8.0 kB CSS (0) | — | — · — · — |
| FieldLabel | 47.7 kB (+22 B) · 5.6 kB CSS (0) | — | — · — · — |
| Overlay | 21.7 kB (+17 B) · 3.9 kB CSS (0) | — | — · — · — |
| TextArea | 58.4 kB (+16 B) · 9.2 kB CSS (0) | — | — · — · — |
| ButtonGroup | 40.1 kB (0) · 3.7 kB CSS (0) | — | — · — · — |
| Timestamp | 23.3 kB (−1 B) · 10.1 kB CSS (0) | — | — · — · — |
Package size: @astryxdesign/core 6.84 MB packed (+1.8 kB); no new dependencies.
API changes: none in this pull request
Committed API report behind this build: cli 19 rows, core 24 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
|
/approve-spec a74129e |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet. It runs once the pull request is marked ready for review and a maintainer adds the ci:run label, since the branch is in a fork.
Both content-touch waits now count from the touch's own timestamp, as spec:AST-094 FR11 asks ("highlights 150 ms after touch-down inside a scroll view"), and the three new explicit-timestamp tests fail without the fix and pass with it.
- Non-blocking: the
msSinceInputJSDoc (packages/core/src/utils/inputAge.ts:16) names "a synthetic event's" time as an epoch time, but in a browser a script-created event is stamped on the page clock; epoch stamps come from DOM emulators such as jsdom.
[Automated review]
0071635 to
a74129e
Compare
|
/approve-spec 29a439a |
There was a problem hiding this comment.
Changes requested: the press-onset fix is right for the page's own document, but it shortens the content-touch wait wrongly for controls rendered into another window's document.
- Miss:
PressTrackersubtracts a touch'stime, stamped on its own document's clock, from this bundle'sperformance.now()(gestures/PressTracker.ts:351-354), so for a Switch, SegmentedControl or Slider inside a scroll view in a same-origin iframe or a second window the 150 ms wait drops to 0 and the highlight comes 101–123 ms after touch-down in Chromium instead of 150 ms; measure the age on the clock of the window that stamped the touch, asGestureHost.ts:1183already does, and add a case to the existing iframe harness.
The new explicit-timestamp tests fail on the old code and pass here, so the main-document fix itself is well proven. The earlier non-blocking note on the inputAge.ts JSDoc wording stays in its thread. Some CI jobs were still running when this was written.
[Automated review]
A touch in a same-origin iframe or a popup carries a time on that window's clock, which starts later than the page's. PressTracker took the touch's age on the page's clock, so the content-touch wait in a scroll view there dropped to about 100 ms. msSinceInput now reads the clock of the window that the touch's target belongs to, as GestureHost does for a mover's age.
|
/approve-spec ddd4d27 |
There was a problem hiding this comment.
Approved pending CI: the CI run on this head stopped at admission because CI was full, so its tests have not run yet. Re-run all jobs of the CI workflow so the required checks run.
Both content-touch waits now count from the touch's own timestamp, as spec:AST-094 FR11 asks, and a touch's age is read on its own window's clock, so a control in a same-origin iframe keeps the full 150 ms. The explicit-timestamp unit tests and the iframe browser case fail against the old code and pass here.
[Automated review]
|
/approve-spec 9d97d51 |
There was a problem hiding this comment.
Requesting changes for one finding. The FR11 timing fix itself checks out: the new explicit-timestamp tests fail with main's code and pass here, and the same-origin iframe case holds in Chromium.
- Miss:
utils/inputAge.tsadds a second implementation of the touch-clock logic thathooks/longPressDetector.tsalready has inclockOfandtimeOn, with a different rule for epoch-millisecond stamps (for the same 60 ms-old stamp the press onset waits 150 ms and the long-press detector 90 ms), so please move those two helpers intoinputAge.ts, buildmsSinceInputon them, and havelongPressDetector.tsimport them.
CI is still running on this head.
[Automated review]
hooks/longPressDetector.ts read a touch's time with its own clockOf and timeOn. utils/inputAge.ts now owns both, and msSinceInput builds on them, so the press onset and the long-press hold read a touch's age the same way. An epoch stamp, as jsdom makes, now keeps its age for the press onset too, as it already did for the hold. The press onset also reads the clock of the event's own window.
|
/approve-spec 5b61705 |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet, because a draft runs no CI, so marking the pull request ready for review starts it.
The earlier finding is fixed: utils/inputAge.ts now owns clockOf and timeOn, msSinceInput builds on them, and the long-press detector imports them, so a touch's age reads the same for the press onset and the hold. Both content-touch waits count from touch-down as spec:AST-094 FR11 requires, and the explicit-timestamp tests fail with main's code and pass here.
[Automated review]
|
/approve-spec f061085 |
User impact
On a phone or a tablet, a pressable inside a scroll view highlights 150 ms after the finger lands, so a flick scrolls without a flash (
spec:AST-094FR11). A busy page runs the touch listener late. The press code started its 150 ms wait only when that listener ran, so the highlight came late by the listener's delay, and by a different amount each time.In the iOS 26.2 Simulator, Mobile Safari ran the listener 8 to 17 ms after the touch, and the highlight came 159 to 169 ms after it. With this change it comes 151 to 155 ms after the touch, in the same session.
Who is affected: every Astryx pressable inside a scroll view, through the shared press controller (buttons, list rows, menu rows, cards), and SegmentedControl, Switch, Slider and
usePressTrackercontrols there, through the gesture system's press tracker. Their highlight is now on time. Outside a scroll view nothing changes: the highlight still comes in the frame the finger lands. A mouse and the keyboard are unaffected.Problem and solution fit
utils/pressFeedback.tsarmed its onset timer as a 150 mssetTimeoutwhen itspointerdownlistener ran.gestures/PressTracker.tsarmedcontentTouchDelaywhen the touch reached it. Both counted from when the code ran, not from the touch.delaysContentTouchesdoes. A highlight that trails by a varying delay reads as lag, and motion that starts with the press mark, such as a ContextMenu trigger's hold growth, inherits it.The fix counts each wait from the touch's own time: an event's
timeStamp, or a gesture touch'stime. The time the page took to run the code comes off the wait. A time that is not on the page's clock (zero, ahead of now, or an epoch time such as a synthetic event's) counts as now, so the wait stays the full 150 ms. Each age is read on the clock of the window the touch landed in: a same-origin iframe's or a popup's clock starts later than the page's.Expected behavior and authority
spec:AST-094FR11: "A cell (a table or collection cell) highlights 150 ms after touch-down inside a scroll view … A control inside a scroll view takes the same 150 ms delay before its highlight and then follows its control profile." Its verification row asks for "press and long-press tests on synthetic streams with explicit timestamps". The record is unchanged: the code now does what it says.Smallest restoration
utils/inputAge.ts(new, internal): one helper owns how old a touch is.clockOffinds the clock of the window that stamped an input (an event'sview, or a node's window, else this window's),timeOnreads a stamp on that clock, andmsSinceInput(time, source)is the input's age, never below 0.clockOfandtimeOncome fromhooks/longPressDetector.ts, which now imports them. Where the two rules disagreed, the long-press detector's wins: an epoch-millisecond stamp, as jsdom makes, keeps its age (a 60 ms-old one now waits 90 ms for the press onset too, as for the hold). Real browsers stamp on the performance clock, so they see no change.utils/pressFeedback.ts:applytakes the touch's age, and the onset timer waits 150 ms less that age, never below 0. The flash and fade timers are unchanged, since each starts with its own paint. It passes the event, so the age reads the clock of the event's own window.gestures/PressTracker.ts:touchBegan'scontentTouchDelaywait loses the touch's age the same way. It passes the touch's target, so a control in a same-origin iframe or a popup reads that window's clock, asGestureHostdoes for a mover's age.hooks/longPressDetector.ts: importsclockOfandtimeOninstead of keeping its own, so the long-press hold reads a touch's age as the press onset does. Its behavior is unchanged.setTimer(event.time + duration)), so the action groups' long-press tracking needs nothing.No API, record, default or visual change.
Evidence
pointerdown's owntimeStamp. On main (3bd058c) the listener ran at 8–17 ms and the mark came at 159–169 ms (6 rounds).msSinceInputignoring the target's window, or PressTracker passing no target, the browser case fails 3 of 3.msSinceInput(60) and to the long-press detector (its 500 ms hold fires at 440 ms). With the previousinputAge.ts,longPressDetector.tsandpressFeedback.ts, it fails, as do the new epoch-stamp cases in the inputAge and pressFeedback suites. The long-press suites pass unchanged.pointerdown'stimeStamp, not from its listener, since the claim counts from the touch.Scope
Testing
To check by hand, on an iPhone or the iOS Simulator, in the press feedback "Buttons in a scroller" story: hold a finger on a button. The highlight comes about 150 ms after the touch, also on a busy page. A flick still scrolls with no flash, and a button outside the scroller still highlights as the finger lands.
What was run at this head (main a888b3d merged in), after a fresh
pnpm install --frozen-lockfile, with Storybook built from this head's code.CI=true pnpm linton the changed files, strict ESLint and Prettier on them,check:knowledge, changeset coverage andreview:prepass.test:node17,024 passed, 2 expected failures, 71 skipped, 0 failed (944 files).test:ui22,131/22,131. The pressFeedback, PressTracker,inputAge, long-press detector anduseLongPresssuites 151/151. With main'spressFeedback.tsandPressTracker.ts, the three timing cases fail. With the page's clock ininputAge.tsandPressTracker.ts, the two iframe-clock cases fail. With the previousinputAge.ts,longPressDetector.tsandpressFeedback.ts, the shared-rule case and the epoch-stamp cases fail.gestures.interaction: 203 passed and 5 skipped by engine gates.--cpus=4 -e CI=1 -e LP_NUM_THREADS=4 --cpuset-cpus=0-99, 1 worker): the same 9 files, 171 passed and 37 skipped by engine gates.