You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4372170
Browse filesBrowse the repository at this point in the historyBrowse files
fix(core): a long press held through a busy main thread still reports, on the touch events' clock
useLongPress timed a hold with a page timer set at touchstart and cleared
by touchend. When the main thread was busy through the hold, the page ran
the queued touchend before the overdue timer, and the long press was lost:
a Table cell's ContextMenu opened nothing after an 800 ms hold.
spec:AST-094 FR16 asks a gesture to keep the event clock: a blocked main
thread delays the report and never the moment reported.
- The hold is a deadline on the touch events' own timestamps
(touchstart.timeStamp + delay). A move, a second finger, or a lift
stamped at or past it reports the pending press first, at its start
point, then acts.
- The page timer waits only for what is left of the hold, so a touch the
page handled late does not lengthen it. A timer that fires late yields
once to queued input, so a lift stamped before the deadline still
cancels the press: the gesture arena's rule (gestures/GestureArena.ts).
- The clock is the touch's own window's, (e.view ?? window).performance,
captured at touchstart: a same-origin iframe or a Picture-in-Picture
window has its own time origin. Epoch stamps (jsdom) come onto it through
its time origin, and the timer never waits past the delay.
- onTouchEnd and onTouchCancel take the touch event, optionally;
ContextMenu passes it.
Tests: useLongPress's event-clock cases (six fail on main), among them a
touch on a window clock whose origin is later than the page's, and a
TableCellMenus browser case whose first long press is held through a
1,200 ms busy main thread (fails on main). A [fix] changeset.
[fix]`useLongPress` times a hold on the touch events' own timestamps (`spec:AST-094` FR16). When a busy page handles the lift late, a finger held for the full delay still reports its long press before the lift acts, instead of losing it, so a ContextMenu's long press opens on a loaded page too. A touch the page handled late no longer lengthens the hold, and a lift stamped before the deadline still cancels the press when its timer ran late. `onTouchEnd` and `onTouchCancel` take the touch event, optionally; spreading the handlers passes it.
Copy file name to clipboardExpand all lines: packages/core/src/hooks/useLongPress.doc.mjs
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -59,7 +59,7 @@ export const docs = {
59
59
],
60
60
usage: {
61
61
description:
62
-
'Detects a single-finger press-and-hold and reports where it happened, so touch users can reach affordances that a pointer gets from right-click. iOS Safari never synthesizes a contextmenu event on long-press, which makes this the only touch route into a cursor-positioned surface such as ContextMenu. The press cancels on movement, lift, multi-touch or unmount.',
62
+
'Detects a single-finger press-and-hold and reports where it happened, so touch users can reach affordances that a pointer gets from right-click. iOS Safari never synthesizes a contextmenu event on long-press, which makes this the only touch route into a cursor-positioned surface such as ContextMenu. The press cancels on movement, lift, multi-touch or unmount. The hold is timed on the touch events\u2019 own timestamps: when a busy page handles the lift late, a finger held for the full delay still reports its long press, before the lift acts.',
63
63
bestPractices: [
64
64
{
65
65
guidance: true,
@@ -102,7 +102,7 @@ export const docsDense = {
102
102
},
103
103
usage: {
104
104
description:
105
-
'Touch press-and-hold for affordances a pointer reaches by right-click (e.g. ContextMenu). Reports the point so the surface opens under the finger.',
105
+
"Touch press-and-hold for affordances a pointer reaches by right-click (e.g. ContextMenu). Reports the point so the surface opens under the finger. Timed on the touch events' timestamps: a busy page delays the report, never drops it.",
0 commit comments