Skip to content

feat(ContextMenu): a held finger grows the trigger on UIKit's lift spring - #9816

Draft
vjeux wants to merge 160 commits into
meta:mainfrom
vjeux:uikit/c20-contextmenu-growth
Draft

vjeux wants to merge 160 commits into
meta:mainfrom
vjeux:uikit/c20-contextmenu-growth

Conversation

@vjeux

@vjeux vjeux commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Stack: #11837 → #8125 → #9816 → #8133 → #8201
Merge group: #8125, #9816, #8133

Behavior module: ContextMenu's press feedback.

User need

A held finger should see the trigger grow from 150 ms, as UIKit's view does, before the menu at 735 ms.

Problem and solution fit

  • The growth starts at the first frame at or after the touch's timestamp plus 150 ms, from rest, toward 1.0735× on springs.contextMenuLift.
  • It returns on springs.contextMenuDismiss when the hold ends with no menu or the menu closes, and holds while the menu is up.
  • None inline, behind a sheet, or under Reduce Motion. A nested trigger grows alone. An enabled trigger joins core's press machine.
  • The growth scales an inner box holding the trigger's children; the menu's anchor stays on the untransformed trigger (architecture:layer-runtime INV22).

Current specification

component:ContextMenu FR5 (since #9915) makes the long press a gesture component: the lift plays springs.contextMenuLift, the return springs.contextMenuDismiss (spec:AST-094 FR7, FR45). FR12 adds the growth on those springs. design:reduced-motion governs.

Public delta and caller burden

No API change. A block trigger grows about 7%; its docs ask for room. Its children sit in one inner box, laid out as before. The motion engine loads with the touch layer, after first paint. First-load gzip over #8125: menu +255 B, table +234 B.

Design and alternatives

  • A late frame starts a whole grow-in from rest, never a jump into the spring.
  • The springs play on the compositor, so a busy main thread does not stall them.

Evidence

spec:AST-094 Platform support:

  • Chromium (phone emulation) and WebKit (CI profile): the long-press spec's proofs, red first (Testing).
  • iOS 26.2 Simulator at efe3f12 (same motion): a 400 ms block freezes the frame clock 23 frames while the card keeps growing (strip).
  • Device takes at this head (Android DEC-27, real-device iOS) have not run (Testing).

Scope

  • One capability is added.
  • Unrelated fixes, cleanup, and policy changes were removed or split.
  • Consumer docs, focused tests, and migration evidence ship with the feature.
  • Public text and artifacts contain no internal Meta context.

Writing rubric results

Over component:ContextMenu: FR12 adds the growth on FR5's springs beside the hold's internal moments; Ownership names the trigger mark's module. Owner-gated.

  • R1 narration: none.
  • R3 evidence: FR12's basis names UIKit's measured moments and growth, and FR5's gesture-component decision.
  • R2 research, R4 rejected alternatives, R5 change references, R6 open questions, R7 project status: none.

Testing

This round, at 9c1cd2b, on main 64806d0:

Local checks at cdd8ebc, one worker:

  • the tests this change reaches on main 64806d0 (test:ui --changed, the boundary test included): 518 files, 15,375 passed;
  • the lazy-sheet and touch-loader boundary tests: 6 passed;
  • 16 interaction specs: ContextMenu's long press, the gesture system, and the touch adopters (BottomSheet, List, Slider, SnapPaging, Switch and the pager). Chromium 379 passed, 15 skipped; WebKit under the CI profile 316 passed, 78 skipped;
  • 9 a11y specs in Chromium, 90 passed. The lift's click proof failed once there, on the touch layer's late load; feat(ContextMenu): open from a held finger on iOS 26's timeline #8125's db994d9 fixes that proof. The cursor-anchor and Layer context-menu specs in WebKit, 7 passed;
  • the Storybook build, the core typecheck, strict eslint and prettier on the changed files, changeset coverage, check:changesets, check:knowledge, check:component-import-boundaries, and pnpm review:pre (0 findings; merges clean).

Final local checks at 8ed1ce9, one worker:

  • the tests this change reaches on main 64806d0 (test:ui --changed, the boundary test included), from a fresh results cache: 518 files, 15,376 passed. Runs that reused an earlier run's order timed out main's semanticFence.shared test at the cold start;
  • the Storybook build, the core typecheck, strict eslint and prettier on the changed files, changeset coverage and check:changesets. Also check:knowledge, check:component-import-boundaries, the shared-identity check (7 passed), and pnpm review:pre (0 findings; merges clean).

This pull request's own change since cdd8ebc is one comment. #8125's changes ran in #8125's browser specs.

At 9c1cd2b, which brings #8125's loader fix, the ContextMenu, Layer, DropdownMenu and useMenuPress units ran again: 1,400 passed. So did the core typecheck, strict eslint, prettier, check:knowledge, the shared-identity check and pnpm review:pre (0 findings; merges clean).

The previous round, at d5a7049:

Local checks at d5a7049, one worker:

  • the tests this change reaches on main 4800d99 (test:ui --changed, the boundary test included): 516 files, 15,337 passed;
  • lazy-sheet-bundle.test.mjs: 4 passed;
  • the long-press and keyboard-capped lists specs, every case three times: Chromium 129 passed, 3 skipped; WebKit under the CI profile 102 passed, 30 skipped;
  • the gesture specs: Chromium 84 passed, 4 skipped; WebKit 76 passed, 12 skipped;
  • in Chromium: the ContextMenu audit, long-press a11y, cursor-anchor, menu hover-focus, ChatComposer dialog and Table resize-edge specs (35 passed); in WebKit: the cursor-anchor spec (3 passed);
  • the core typecheck, strict eslint and prettier on the changed files, changeset coverage, check:changesets, check:knowledge, and pnpm review:pre (0 findings; merges clean).

The previous round, at cda2451:

Local checks at cda2451, one worker:

  • the tests this change reaches on main 4800d99 (test:ui --changed): 515 files, 15,313 passed;
  • the long-press and keyboard-capped lists specs, every case three times: Chromium 117 passed, 3 skipped; WebKit under the CI profile 93 passed, 27 skipped;
  • the gesture specs: Chromium 84 passed, 4 skipped; WebKit 76 passed, 12 skipped;
  • in Chromium: the ContextMenu audit, long-press a11y, cursor-anchor, menu hover-focus, ChatComposer dialog and Table resize-edge specs (35 passed); in WebKit: the cursor-anchor spec (3 passed);
  • the core typecheck, strict eslint and prettier on the changed files, changeset coverage, check:changesets and check:knowledge.

The previous round, at eb3d17d:

Local checks at eb3d17d, one worker:

  • the tests this change reaches on main 36f68b0 (test:ui --changed): 499 files, 14,838 passed;
  • the long-press and keyboard-capped lists specs, every case three times: Chromium 114 passed, 3 skipped; WebKit under the CI profile 90 passed, 27 skipped;
  • the gesture specs: Chromium 84 passed, 4 skipped; WebKit 76 passed, 12 skipped;
  • in Chromium: the ContextMenu audit, long-press a11y, cursor-anchor and menu hover-focus specs (31 passed); in WebKit: the cursor-anchor spec (3 passed);
  • the core typecheck, strict eslint and prettier on the changed files, changeset coverage, check:changesets and check:knowledge.

The previous round, at a42af3e:

Local checks at a42af3e, one worker:

  • the tests this change reaches on main 56680f6 (test:ui --changed): 498 files, 14,750 passed;
  • the long-press and keyboard-capped lists specs, every case three times: Chromium 114 passed, 3 skipped; WebKit under the CI profile 90 passed, 27 skipped;
  • the gesture specs: Chromium 84 passed, 4 skipped; WebKit 76 passed, 12 skipped;
  • in Chromium: the ContextMenu audit, long-press a11y, cursor-anchor and menu hover-focus specs (31 passed); in WebKit: the cursor-anchor spec (3 passed);
  • the core typecheck, strict eslint and prettier on the changed files, changeset coverage, check:changesets and check:knowledge.

The previous round, at cd6d257:

Local checks at cd6d257, one worker:

  • check:knowledge, check:changesets, prettier on the changed files, and strict eslint on the spec;
  • the long-press and keyboard-capped lists specs, every case three times: Chromium 114 passed, 3 skipped; WebKit under the CI profile 90 passed, 27 skipped.

The previous round, at 44ab755:

  • b8c7cb2 merges feat(ContextMenu): open from a held finger on iOS 26's timeline #8125's head 5adbafb, which merges main 50beab9 and fixes the shift cases' timing in the long-press spec. It merges with no conflict, and this pull request's own diff over feat(ContextMenu): open from a held finger on iOS 26's timeline #8125 is unchanged (same patch-id and files).
  • 44ab755, tests only. The case "a touch that reaches the page late grows from the first frame at its onset" failed once in three Chromium runs. Its frame read 149.6 ms after the touch, against 150. The press feedback starts the growth in the first frame whose callback runs at or after the onset. The curve starts when that callback runs. The case checked the frame's own time, which can fall just before the onset. It now checks that the growth animation's own start time is at or after the onset. The two-frame bound stays.
  • Red first: a frame callback that ran 8 ms ahead of the press feedback's widened that gap. The old check then failed 8 of 20 times, at about 142 ms, and the new one passed 20 of 20. Unprobed, it passed 20 of 20.

Local checks at 44ab755, one worker (the unit, gesture and a11y runs at b8c7cb2, which differs only in that spec):

  • the tests this change reaches on main 50beab9 (test:ui --changed): 498 files, 14,722 passed;
  • the long-press and keyboard-capped lists specs, every case three times: Chromium 114 passed, 3 skipped; WebKit under the CI profile 90 passed, 27 skipped;
  • the gesture specs: Chromium 84 passed, 4 skipped; WebKit 76 passed, 12 skipped;
  • in Chromium: the ContextMenu audit, long-press a11y, cursor-anchor and menu hover-focus specs (31 passed); in WebKit: the cursor-anchor spec (3 passed);
  • the core typecheck, strict eslint and prettier on the changed files, changeset coverage, check:changesets and check:knowledge.

The previous round, at c11eb1f:

Local checks at c11eb1f, one worker:

  • the tests this change reaches on main 4d1cb82 (test:ui --changed): 496 files, 14,484 passed;
  • the long-press and keyboard-capped lists specs, every case three times: Chromium 111 passed, 3 skipped; WebKit under the CI profile 90 passed, 24 skipped;
  • the gesture specs: Chromium 84 passed, 4 skipped; WebKit 76 passed, 12 skipped;
  • in Chromium: the ContextMenu audit, long-press a11y, cursor-anchor and menu hover-focus specs (31 passed); in WebKit: the cursor-anchor spec (3 passed);
  • the core typecheck, strict eslint and prettier on the changed files, changeset coverage, check:changesets and check:knowledge.

The previous round, at a1cc302:

Local checks at a1cc302, one worker (the unit, gesture and a11y runs at 01f5f22, which differs only in that spec):

  • the tests this change reaches on main 1740654 (test:ui --changed): 487 files, 14,335 passed;
  • the long-press and keyboard-capped lists specs, every case three times: Chromium 111 passed, 3 skipped; WebKit under the CI profile 90 passed, 24 skipped;
  • the stays-put case ten more times in WebKit: 10 passed;
  • the gesture specs: Chromium 83 passed, 4 skipped; WebKit 75 passed, 12 skipped;
  • in Chromium: the ContextMenu audit, long-press a11y, cursor-anchor and menu hover-focus specs (31 passed); in WebKit: the cursor-anchor spec (3 passed);
  • the core typecheck, strict eslint and prettier on the changed files, changeset coverage, check:changesets and check:knowledge.

The previous round, at 8fc523e:

Local checks at 8fc523e, one worker:

  • the tests this change reaches on main 6ab0c2e (test:ui --changed): 488 files, 14,345 passed;
  • the long-press and keyboard-capped lists specs, every case three times: Chromium 108 passed, 3 skipped; WebKit under the CI profile 87 passed, 24 skipped;
  • the gesture specs: Chromium 83 passed, 4 skipped; WebKit 75 passed, 12 skipped;
  • in Chromium: the ContextMenu audit, long-press a11y, cursor-anchor and menu hover-focus specs (31 passed); in WebKit: the cursor-anchor spec (3 passed);
  • the core typecheck, strict eslint and prettier on the changed files, changeset coverage, check:changesets and check:knowledge.

The previous round, at 8fb305f, from review:

  • da14211 merges feat(ContextMenu): open from a held finger on iOS 26's timeline #8125's head 69e6dd8, whose comments stop naming a press feedback there. The touch layer's header keeps both sides' sentences.
  • cecb382, comments only: the timeline's header and the long-press spec name the press feedback again, since it ships here.
  • 3e17bd2, red first: in a same-origin iframe, a finger's growth starts at that window's onset. That is the first frame at or after 150 ms past the landing. At 850a9c2 it started in the first frame, dated on the page's clock.
  • 69a6851 fixes it. The press feedback reads the trigger's window for its frames and clock, and for another window its animator runs on that window's clock and frames. The page's own document keeps the defaults. A comment that only restated a name goes.
  • 1d6ec37, records only: the End-user impact row drops its "does not yet" sentence, a gap that Current-state impact states against FR5.
  • 8fb305f, comments only: the press feedback's file comment keeps one line; the rest repeated the hook's JSDoc.

Local checks at 1d6ec37, one worker (8fb305f changes one comment):

  • the tests this change reaches on main b8835b8 (test:ui --changed): 485 files, 14,214 passed;
  • the long-press spec, every case three times: Chromium 87 passed, 3 skipped; WebKit under the CI profile 66 passed, 24 skipped;
  • the keyboard-capped lists spec: Chromium 7 passed; WebKit 7 passed;
  • the gesture specs: Chromium 77 passed, 4 skipped; WebKit 69 passed, 12 skipped; presented hit testing 6 passed in each;
  • in Chromium: the ContextMenu audit (18 passed), long-press a11y (3 passed), cursor-anchor (3 passed) and menu hover-focus (7 passed) specs;
  • in WebKit: the cursor-anchor spec (3 passed);
  • the core typecheck, strict eslint and prettier on the changed files, changeset coverage, check:changesets and check:knowledge.

The previous round, at 850a9c2:

  • 4e93b5f replaces the module-level set of mounted triggers with a private attribute, data-astryx-context-menu-trigger, written and read through one owner module. A nested trigger still grows alone.
  • f908089, records only: component:ContextMenu's Ownership names that module, its writer and its reader.
  • 850a9c2 merges feat(ContextMenu): open from a held finger on iOS 26's timeline #8125's head fac565a. ContextMenuTouch.ts goes, so the touch layer imports contextMenuPress and contextMenuPressFeedback directly. A press that ends with no menu springs back and releases what the commit mounted. The long-press spec keeps both pull requests' cases.

Local checks at 850a9c2, one worker:

  • the tests this change reaches on main b8835b8 (test:ui --changed): 485 files, 14,213 passed;
  • the long-press spec, every case three times: Chromium 87 passed, 3 skipped; WebKit under the CI profile 66 passed, 24 skipped;
  • the keyboard-capped lists spec: Chromium 7 passed; WebKit 7 passed;
  • the gesture specs: Chromium 77 passed, 4 skipped; WebKit 69 passed, 12 skipped; presented hit testing 6 passed in each;
  • in Chromium: the ContextMenu audit (18 passed), long-press a11y (3 passed), cursor-anchor (3 passed) and menu hover-focus (7 passed) specs;
  • in WebKit: the cursor-anchor spec (3 passed);
  • the core typecheck, strict eslint and prettier on the changed files, changeset coverage, check:changesets and check:knowledge.

The previous head, 0b1f31c, merged #8125's head cae3644 with no conflict. There the press reads the page's time from the arena's injected clock, which is performance.now() in a browser. Before it, 2a36eba merged #8125's 45bfb44. There a menu timer that runs more than a frame late waits up to 50 ms for moves queued behind the block. 782cdbd merged #8125's cad79ec. There the press judges each coalesced sample at its own time. The menu waits at its moment only when the page is behind its input, so an on-time finger gets it at 735 ms. Before that, e25ec8c merged #8125's 88cc0d8, and its one conflict dropped the touch layer's pointer follow. Before that, c346da0 merged #8125's a4e0404, and three commits answer the review of 2ef1714:

  • d26b15b adds a set-height trigger with a full-height child to 'Touch / trigger layouts' and its layout case. It fails at that commit: the child measured 24 px in the 160 px trigger.
  • 7d23141 makes the inner box take the trigger's height in block layout, as it already does in flex and grid.
  • a75cf09 checks that the trigger keeps its own attributes, and that the inner box carries only its class.

Under a fine pointer, all 31 ContextMenu story captures match main's pixel for pixel: 18 stories at rest, 13 with the menu open. That ran at 55f84be, whose ContextMenu.tsx differs from 850a9c2's in one comment line. The change adds no public data-* attribute; 4e93b5f's private data-astryx-context-menu-trigger has its owner module (INV23).

Local checks at 0b1f31c, one worker:

  • the long-press spec: Chromium 28 passed, 1 skipped; WebKit under the CI profile 22 passed, 7 skipped;
  • the keyboard-capped lists spec: Chromium 7 passed; WebKit 7 passed;
  • the gesture specs: Chromium 76 passed, 4 skipped; WebKit 68 passed, 12 skipped; presented hit testing 6 passed in each;
  • the ContextMenu audit (18 passed), long-press a11y (3 passed) and cursor-anchor specs in Chromium (3 passed), and the cursor-anchor spec in WebKit (3 passed);
  • the ContextMenu, Layer, motion, DropdownMenu, hooks, gestures, utils and lift units (5,369 passed), the core typecheck, eslint, check:changesets and check:knowledge.

The previous head, 2ef1714, sat on a merge of #8125's head a5a0e12 (704cff3). The one conflict put two new browser cases side by side in the long-press spec. Three commits follow:

  • 06c942c adds the cases for architecture:layer-runtime INV21 and INV22 (spec:AST-059 DEC-9 and DEC-10, from #11024). A finger's or a pen's press leaves the open menu as an unpressed open. A layout case checks block, row and grid triggers against plain boxes.
  • 597e158 grows an inner visual box, and the touch changeset says so. The anchor stays outside it, and the script that cancelled the scale at the anchor is gone.
  • 2ef1714 turns the long-press cases' fifteen fixed waits into conditions. Each waits on the page clock from the touch, the menu's moment plus a task, the lift plus a frame, or a settled menu.

Red first, at fb27cdc (the same tree as 06c942c), in Chromium and WebKit: the press cases fail. The menu's box matched, but the trigger above the anchor carried scale 1.0735, and the anchor carried an inline counter-scale and translate. The layout case passed, as it should with no inner box.

Local checks at 9de7a99, which differs from 2ef1714 only in that changeset sentence, one worker:

  • the long-press spec: Chromium 25 passed, 1 skipped; WebKit under the CI profile 19 passed, 7 skipped. Twice more each: Chromium 50 passed, 2 skipped; WebKit, with the keyboard-capped lists spec, 52 passed, 14 skipped;
  • the keyboard-capped lists spec in Chromium (7 passed);
  • the ContextMenu audit in Chromium (18 passed);
  • the cursor-anchor, long-press and menu hover-focus a11y specs in Chromium (13 passed), and the cursor-anchor spec in WebKit (3 passed);
  • the ContextMenu, Layer, motion, DropdownMenu and hooks units (3,317 passed), the core typecheck, eslint, check:changesets and check:knowledge.

Before and after, a finger held near the card's corner, at 450, 900 and 1,400 ms. The top row is before the inner box, the bottom row 850a9c2. The menu opens at the same place under the finger, and only the card grows: capture.

At earlier heads, below, "this head" means cc254d7.

Android exit timing (contextmenu-default): main none/70 ms, head none/90 ms (6 interleaved rounds; main max gap 107 ms)

Frames, not timers, decide the onset: Chromium holds a page's timers for about 100 ms after it handles a touchstart.

Replayed onto main cd748d0 after #9814's squash: 1cedda2 carries this pull request's earlier own diff (old head 63c7a6c). Its message lists the folded commits, and the newer commits sit on top of it. It sits on #8125's 3d78dae, which now carries the menu's commit inside its deciding task and its commit-time mount. With those, this head's ContextMenu files equal 0c316d9's plus #8125's second-document test, its 735 ms proof, its PR1 sentences and one lint-directive comment line. So the menu behaves the same. The tree also carries main 92784f6, which #8125 merges. Commits c9d07a9 and cc254d7 merge #8125's heads. FR8 keeps main's text from #10160 in this pull request's table. Red first: 791357d (a touch 90 ms late, 3 of 3 red before the frame watch).

Touch to first grown frame, Chromium phone profile: 170–173 ms at normal speed and 164–182 ms at 4× CPU. With a 60 ms input lag, it is 166–167 ms (183 ms, at 1.0110, before the frame watch). Each first frame shows the spring's one-frame value, 1.0033, after an exact 1.000. A quick tap starts no animation and writes no style. The touch handlers' cost does not change. It is 1.50 / 1.85 ms at 1× (1.50 / 1.70 ms before) and 6.60 / 7.95 ms at 4× (6.70 / 8.30 ms before).

A lift between the commit and 735 ms shows the menu 2–3 ms into the lift's own dispatch in WebKit. Before #8125's commit-time mount, it took 17 ms. The lift proof, d44956d, asserts that dispatch, not a time. Under Reduce Motion, the 735 ms proof also wants the show inside its deciding task (4edb900).

App-level size and the eager-animator bundle row measured then predate the deferred touch layer, so they no longer hold. This round's first-load figures replace them.

Local checks at an earlier head, cc254d7, which adds only #8125's two record sentences: check:knowledge. At c9d07a9: ContextMenuLongPress in Chromium (21 passed, 1 skipped) and in WebKit under the CI profile (17 passed, 5 skipped). At 343df06, which differs only in #8125's 735 ms proof: core typecheck; the ContextMenu, Layer and DropdownMenu units (1,135 passed); CI=true pnpm lint (0 errors); check:knowledge. At the stack's top on the same main, the ui suite passed 22,774. DropdownMenuLazySheet's keyboard-open case failed once under load, and it passes alone on main and here. The node suite (test:node) passed 17,446; its one failure is the WebKit leg budget (see #8133). Earlier versions of this description said CI=true pnpm lint, but those runs were pnpm lint, which reports @eslint-react/dom-no-flush-sync only as a warning; that claim is corrected here.

The Android run at an earlier head, cc254d7 (Chrome with Gboard; normal, 4× CPU and animations removed):

  • the growth starts 151 ms after the landing (164 ms at 4×), with no back-dated start, and peaks at 1.0746;
  • an early lift returns in 314 / 327 ms, and the return as the menu closes takes 297 / 307 ms;
  • with animations removed, there is no growth and no return.

Earlier, at 0c316d9, the takes were Chrome with Gboard: normal ×2, 4× CPU ×2 and animations removed ×2. There, the growth animation's start time is 152–165 ms after the landing. It starts from 1.000 (first frames 1.000, then 1.002–1.005), with no back-dated jump. This head carries 0c316d9's ContextMenu files apart from one lint-directive comment line, and it also carries main's own changes. Both returns take about 285–354 ms, and Reduce Motion shows no growth. At 63c7a6c, an earlier head, the animation was created about 238 ms after the landing with a back-dated start. So its first painted frame was already at 1.016–1.039 after an exact 1.000.

Public and internal API delta

Public: none.

Internal, new:

  • privateAttributes/contextMenuTrigger.stylex.ts: the owner module of the private data-astryx-context-menu-trigger attribute (architecture:public-component-api INV23), named in component:ContextMenu's Ownership. markContextMenuTrigger(trigger) marks a trigger while its touch press feedback is attached and returns the call that unmarks it. closestContextMenuTrigger(element) finds the trigger a press belongs to. Usage: const unmark = markContextMenuTrigger(trigger);.
    Why: a press on a nested trigger grows only that trigger. Existing ones considered: data-astryx-pressable, which also sits on every pressable control inside a trigger. So the nearest one can be a nested control, not the trigger. A module-level set of mounted triggers came before; the mark replaces it.
  • ContextMenu/contextMenuPressFeedback.ts: useContextMenuPressFeedback, the trigger's growth (component:ContextMenu FR12), used only by the touch layer. Usage: const feedback = useContextMenuPressFeedback(triggerRef, visualRef, isShown, isFollowedRef);.
    Why: the growth's timing is ContextMenu's own. It starts 150 ms after the landing the recognizer records, holds while the menu is up, and plays UIKit's springs. Existing ones considered: core's press machine (utils/pressFeedback.ts). Its mark comes late inside a scroll view, and never for a press that travels past 10 px first. So the hook times a finger and a pen from the landing.

Lines, over #8125's head:

  • product +474/−21 (contextMenuPressFeedback.ts +296, ContextMenu.tsx +60/−6, ContextMenuTouchLayer.tsx +50/−7, motion/uikit/contextMenu.ts +35/−8, privateAttributes/contextMenuTrigger.stylex.ts +27, contextMenuPress.ts +6);
  • tests +2,249/−104, records +38/−33, docs +19/−4, story +120/−2, changesets +1/−1.

@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 15, 2026 4:41pm 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 15, 2026, 5:20 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 added the needs:design-review Affects visuals — Design should review label Nov 3, 2026
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 3, 2026
@cixzhang

cixzhang commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 578373e

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

Current run: The current CI run concluded skipped. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

@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 spec side is settled: an engineering owner approved ContextMenu FR11 at this head. Each item below still needs a fix before this can merge.

  • The growth and its early-lift return read the generic --duration-medium, --duration-fast and --ease-move tokens, which spec:AST-094 FR4 does not allow for touch motion ("MUST be a motion role named for its use"), so amend FR4 in this pull request or move the growth onto named motion roles.
  • If isDisabled turns true while a finger-opened menu is up, the touch layer unmounts and disposes its animator without restoring the trigger's inline scale, so the trigger stays about 7% larger after the menu closes (contextMenuPressFeedback.ts, the unmount cleanup).
  • ContextMenu now has two outside-press paths, the shared watchOutsidePress for touch and its own mousedown Effect with a different shadow-root rule for everything else, so extend the shared watch to close at the press for a mouse and a pen and delete the Effect (architecture:react-component-runtime INV16).
  • useContextMenuPressFeedback runs its own attach, replace and dispose lifecycle for its animator and press observer, so move both onto useAttachment, which the same layer's useGestureRecognizer already uses.
  • The outside-press changeset says "No component passes these options yet", but ContextMenu passes all three at this head, so reword it.
  • The diff against main is 4,013 authored lines because it carries #9814 and #8125, so land those first or base this branch on #8125 to leave this pull request's own 1,915 lines.

A few smaller comment and wording notes are inline.

[Automated review]

Comment thread .changeset/outside-press-pan-watch.md Resolved
@vjeux
vjeux force-pushed the uikit/c20-contextmenu-growth branch from 578373e to 0d1fdb7 Compare November 3, 2026 22:56
@cixzhang

cixzhang commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 0d1fdb7

@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 spec side is settled: an engineering owner approved ContextMenu FR11, and that approval still covers this head.

  • The growth and its early-lift return play the generic --duration-medium, --duration-fast and --ease-move tokens, which spec:AST-094 FR1 and FR4 do not yet allow for touch motion, so rebase after #9706 lands and cite its FR45 in FR11, or amend FR1 and FR4 here.
  • ContextMenuTouchLayer subscribes to its recognizer's transitions from an Effect whose only dependency never changes, so add that listener in the recognizer factory passed to useGestureRecognizer and delete the Effect.
  • ContextMenuPressRecognizer gains an onPressStart option that only a unit test passes, and its doc says the press feedback starts from it, so remove the option.
  • The diff against main is 4,132 authored lines because it carries #9814 and #8125, so land those first, or declare the stack with one identical Stack: #9814 → #8125 → #9816 line in all three descriptions.

Thanks for fixing the stuck trigger scale and moving the press feedback onto useAttachment. The changeset and the story still say the trigger "springs back" after an early lift, which FR11 now times as a curve on the theme's tokens.

[Automated review]

@vjeux
vjeux force-pushed the uikit/c20-contextmenu-growth branch from 0d1fdb7 to caf271c Compare November 4, 2026 09:37
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 4, 2026
@cixzhang

cixzhang commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

/approve-spec caf271c

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 4, 2026

@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 for this stack: #8125 is ready, and #9814 and #9816 each need one fix. A pull request lands only when it and every pull request below it are approved.

#9814: changes requested

  • Miss: the title and .changeset/outside-press-pan-watch.md say the watch can now "judge a press inside a shadow root", but a press inside an open shadow root was already judged through the event's composed path and every new test uses a closed root, so please say "closed shadow root" in both.

#8125: approved

Approved pending CI: CI has not run on this head yet, and it lands after #9814.

#9816: changes requested

  • Miss: PressTiming and timedCurve in contextMenuPressTiming.ts, and themeTiming in contextMenuPressFeedback.ts, copy ThemeTiming, timedCurve and themeTimingOf from SegmentedControl/useSegmentedSelectionMotion.ts, so please move them into one shared motion module that both components call.
  • Non-blocking: ContextMenu FR11 at this head no longer cites the measurement behind the 400 ms commit and 735 ms display, or the tests that verify them, which #8125's FR11 did.

Whole stack

The combined change adds no public API and follows spec:AST-094 and ContextMenu FR11, but it passes only once the two fixes above land.

[Automated review]

Comment thread .changeset/outside-press-pan-watch.md Resolved
@vjeux
vjeux force-pushed the uikit/c20-contextmenu-growth branch from b168c85 to 037a530 Compare November 4, 2026 10:36
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 4, 2026
@cixzhang

cixzhang commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 037a530

vjeux added 24 commits November 14, 2026 23:10
From review: the late deadline's wait reads no pointer kind and can
re-arm itself.

- A mouse's late deadline keeps the one-task yield it has on main,
  with no wait. The Pager's mouse catch case returns to main's form.
- A pen's late deadline waits, as a finger's does.
- A wait whose own timer runs late, with nothing queued, runs the
  deadline instead of waiting again.
From review, and the owners' ruling on desktop timing:

- A late deadline waits for queued input only while the latest
  contact is a finger or a pen, and only their late input keeps it
  waiting. A mouse or trackpad keeps the one-task yield it has on main.
- Only the deadline's own timer counts as late. A wait whose own
  timer runs late runs the deadline, since only input from before the
  deadline extends a wait.

spec:AST-094 FR16 states the gate, and its cost line names a finger's
or pen's deadline. The changeset names the gesture arena's users only.
Brings the arena fix's 640bbfa and b7e19e3: a late deadline
waits for queued input only while the latest contact is a finger or a
pen, and a wait's own late timer does not re-arm it. ContextMenu's
touch hold is a finger's or pen's, so it keeps the wait. No conflicts.
Brings meta#8125's merge of the arena fix's finger and pen gate. No
conflicts.
The header's sentence on the late wait ran past 25 words. It is now
two sentences. No code changes.
From review's two non-blocking notes:

- spec:AST-094 FR16's third sentence now uses the first sentence's
  gate, "while the latest contact is a finger or a pen", as the arena
  does. It no longer names a finger's or pen's deadline.
- GestureArena.ts drops the two comments that restated
  isFingerOrPenContact and isFingerOrPen. noteArrival's comment now
  says why only a finger's or pen's late input is noted.

No code changes.
Main's meta#11735 re-aligned spec:AST-094's verification table and widened
its FR5 row. The one conflict is that table. The merge takes main's
table and re-applies this pull request's two additions to the
FR15-FR17 row: the late-deadline cases and the failure they catch.
Brings the arena fix's ec2e905: main 64806d0, FR16's third
sentence in the first sentence's gate, and two dropped comments. The
one conflict is spec:AST-094's verification table, which main's
meta#11735 re-aligned. The merge takes main's table and re-adds this pull
request's FR43 late-begin row.
spec:AST-094's FR16 gap note said a late deadline waits 50 ms or more.
Since the arena fix, that holds only while the latest contact is a
finger or a pen, as FR16 says. ContextMenu's touch hold is a finger's
or a pen's, so its menu can still show that much later.
Brings meta#8125's merge of the arena fix's main merge (main 64806d0)
and its FR16 gap note. No conflicts.
The proof turned touch on only after the page loaded, then pressed at
once and gave the menu 2 s. The touch layer loads after the first
paint, when the page is idle, within 2 s. A finger that lands sooner
starts its hold only when the layer mounts. On a busy machine the menu
then opened after 2 s, and the proof failed.

Touch is now on from the first paint. In the touch-model case the
proof waits for the layer's chunk, its module and two frames, as the
interaction proof does, then presses. The popover story keeps today's
long press and loads no layer, so it does not wait. With the chunk
held 2.5 s, the old proof fails and the new one passes.
Brings meta#8125's test fix: the lift's click proof turns touch on from
the first paint and waits for the touch layer. No conflicts.
After a failed load, only a touch on a trigger should ask again. A
trigger that mounts is no intent, so it must start no load. This case
fails here: the failure path clears the windows that scheduled the
load, so the next trigger to mount schedules a new one.
The failure path cleared the windows that had scheduled the load, so
the next trigger to mount started a new load with no intent. The
windows now keep their mark, and only a touch on a trigger asks again,
as the touch layer's load rule says.
The comment said a finger's pointerdown follows its touchstart "as in
WebKit", with no record or probe behind it. It now names only the
order it handles.
The shared-identity check flags four module-scope bindings in the
touch loader: its state, the windows that scheduled the load, the load
in flight and the listeners. Each copy of Core loads and renders its
own touch layer, whose component reads that copy's contexts, so the
state stays per copy. The baseline allows the four with that reason.
Brings meta#8125's fixes from review: after a failed load only a touch
asks again, the pointer-order comment, and the touch loader's
per-copy state in the shared-identity baseline. No conflicts.
From review: one sentence of the press feedback's growth comment ran
26 words. It is now two: the press machine never ends the growth; the
recognizer ends it, and the menu holds and returns it.
The public hook stripped prepare() and releasePrepared() from its
return with a memo and a rest copy, on every page that uses a layer.
Only ContextMenu calls them, through useLayerInternal. The public
type already hides them, so the hook now returns the object as is.
A page with DropdownMenu but no ContextMenu drops 25 B gzip.
Brings meta#8125's change that hides prepare() from the public useLayer by
type only, sparing every page with a layer the runtime strip. No
conflicts.
From review: after a failed load, a trigger whose window never
scheduled the load, such as one in a same-origin frame, still starts
one when it mounts. Only a touch should ask again, in every window.
This case mounts such a trigger after the failure; it fails here.
After a page-wide failure, a trigger whose window had not scheduled
the load still scheduled one as it mounted, with no intent. The load
now waits for a touch in every window: scheduleLoad does nothing once
the latest load has failed.
From review: since add87da the public useLayer returns the
implementation's object, so it carries prepare() and releasePrepared()
at runtime. Only its return type leaves them out. The layer-runtime
record now says so.
Brings meta#8125's fixes from review: after a failed load no window
schedules another, and the layer-runtime record says prepare() is
hidden from useLayer's type only. No conflicts.
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 9c1cd2b

@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: one evidence item remains, and no code change is needed. An engineering owner approved the record changes at this head, and every behavior and API change matches a current or owner-approved claim.

Required

  • Take the touch-presentation spec's real-device iOS run and its Android-emulator runs (Chrome with Gboard, animations at normal scale and removed, plus a slow-device profile) at the head that lands, and state each in the description's text, because the earlier runs do not carry over this head's changes to ContextMenu.tsx, ContextMenuTouchLayer.tsx, contextMenuTouchLoader.ts and the gesture arena and host.

Non-blocking

  • ContextMenu.spec.md Current-state impact still says ContextMenu owns its outside-press listener, which FR10's new gap text replaces.
  • Two comments in ContextMenu.tsx could be tighter: rename toTriggerLocal to toAnchorLocal, and split the 28-word sentence about Android's own long-press menu.

The fixes since the earlier review hold: the description's first-load figures, the failed-load fallback, and a clean merge with main.

Claims and files checked

Review mode: same-head; reason: none

Claims:

  • Outside press goes through the layer's watch; a mouse or pen press closes at its mousedown in the menu's own document, so an iframe or Picture-in-Picture menu no longer closes on a page press — verified (ContextMenu.tsx:669-692, outsidePress.ts:226-245, the second-document unit case)
  • A held finger opens the menu on the measured iOS timeline where the primary pointer is coarse — verified (ContextMenu.tsx:452, contextMenuPress.ts, the 735 ms unit cases)
  • A block trigger whose menu opens at the finger grows from 150 ms toward its held size on the lift spring, on the compositor — verified (contextMenuPressFeedback.ts:173-200, :257-293; phone-profile capture at 1.0735)
  • The growth scales an inner box, so the menu never takes the press's scale — verified (ContextMenu.tsx:1182-1188, the layer-runtime browser case, the capture's unchanged menu position)
  • At 400 ms the press takes the finger: its lift sends no click and the page cannot scroll under it — verified (contextMenuPress.ts:175-191, unit 'claims the finger at the commit')
  • The menu opens at 735 ms for a finger still down, or at a lift after 400 ms — verified (unit cases; the 650 ms capture opens at the lift)
  • A lift before 400 ms or a drift past 11.5 px on either axis gives no menu, and the trigger springs back — verified (contextMenuPress.ts:133-168, ContextMenuTouchLayer.tsx:120-125)
  • The page stays free to scroll; a touch outside closes the menu as it pans or at its lift — verified (ContextMenu.tsx:685-689, unit pan cases)
  • The trigger returns to its size when the menu closes — verified (ContextMenu.tsx:517-519, contextMenuPressFeedback.ts:226-237)
  • A touch open lights no row; keyboard and pointer opens focus the first item — verified (capture: focus on the menu; unit focus cases)
  • A second finger cancels before 400 ms; after it, the menu still opens — verified (contextMenuPress.test.ts)
  • A fine pointer keeps the right-click menu, and a finger there keeps the 500 ms long press — verified (fine-pointer unit cases; pixel-identical right-click capture)
  • The touch code loads after first paint; a finger held earlier starts its hold when it loads — verified (contextMenuTouchLoader.ts:99-116, the boundary test, the before-load cases)
  • presentation="popover" keeps the released menu and 500 ms long press — verified (unit case, popover story)
  • A finger's or pen's deadline whose timer runs over 17 ms late waits 50 ms, each late earlier input extends the wait, a mouse or trackpad does not wait, and coalesced samples straddling a deadline are split — verified (GestureArena.ts:1121-1146, :1294-1337, the late-deadline unit cases)
  • A List reorder hold or a Pager catch whose finger drifted or lifted in time now ends as it should — verified through the shared arena deadline (the reorder hold is a long-press recognizer; the Pager test shows its catch waiting on the arena), not reproduced per component
  • Description: the growth starts in the first frame at or after the onset, from rest, and returns on the dismiss spring; none for an inline trigger, a sheet or Reduce Motion; a nested trigger grows alone — verified (contextMenuPressFeedback.ts:173-200, ContextMenu.tsx:1205, contextMenuTrigger.stylex.ts)
  • Description: no API change — verified for this pull request's own part over #8125; judged against main it also carries #8125's recorded presentation default move
  • Description: the motion engine loads with the touch layer, after first paint — verified (only contextMenuPressFeedback.ts imports the animator, reached through the loader's dynamic import)
  • Description: first-load gzip figures over #8125 and over main — stated, not re-measured
  • Description: device takes at this head have not run — verified (the blocking item)
  • Description: local check runs at earlier heads — describe earlier heads and were not rechecked; the unit run at this head passed 923 tests

Files:

  • .changeset/contextmenu-outside-press-watch.md — clear
  • .changeset/contextmenu-touch-timeline.md — clear
  • .changeset/gesture-arena-late-input.md — clear
  • apps/storybook/stories/ContextMenu.stories.tsx — clear
  • docs/architecture/layer-runtime.md — clear (owner-approved)
  • docs/specs/AST-094-touch-presentations/spec.md — clear (owner-approved)
  • docs/specs/components/ContextMenu/ContextMenu.spec.md — owner-approved; non-blocking: a Current-state line still says ContextMenu owns its outside-press listener
  • packages/core/src/ContextMenu/ContextMenu.doc.mjs — clear
  • packages/core/src/ContextMenu/ContextMenu.tsx — non-blocking comment suggestions (two)
  • packages/core/src/ContextMenu/ContextMenu.test.tsx — clear
  • packages/core/src/ContextMenu/ContextMenu.touchLoadFailure.test.tsx — clear
  • packages/core/src/ContextMenu/ContextMenu.triggerProps.test.tsx — clear
  • packages/core/src/ContextMenu/ContextMenuTouchGrowth.test.tsx — clear
  • packages/core/src/ContextMenu/ContextMenuTouchLayer.tsx — clear
  • packages/core/src/ContextMenu/ContextMenuTouchLayerProps.test.tsx — clear
  • packages/core/src/ContextMenu/__tests__/ContextMenuLongPress.a11y.chromium.spec.ts — clear
  • packages/core/src/ContextMenu/__tests__/ContextMenuLongPress.interaction.browser.spec.ts — clear
  • packages/core/src/ContextMenu/contextMenuPress.test.ts — clear
  • packages/core/src/ContextMenu/contextMenuPress.ts — clear
  • packages/core/src/ContextMenu/contextMenuPressFeedback.test.tsx — clear
  • packages/core/src/ContextMenu/contextMenuPressFeedback.ts — clear
  • packages/core/src/ContextMenu/contextMenuTouchLoader.boundary.test.ts — clear
  • packages/core/src/ContextMenu/contextMenuTouchLoader.ts — clear
  • packages/core/src/Indicator/boxHold.test.tsx — clear
  • packages/core/src/Layer/outsidePress.test.ts — clear
  • packages/core/src/Layer/outsidePress.ts — clear (behavior tag-along note only)
  • packages/core/src/Layer/useLayer.test.tsx — clear
  • packages/core/src/Layer/useLayer.tsx — clear
  • packages/core/src/gestures/GestureArena.ts — clear
  • packages/core/src/gestures/GestureHost.ts — clear
  • packages/core/src/gestures/__tests__/GestureHost.test.ts — clear
  • packages/core/src/gestures/__tests__/arena.test.ts — clear
  • packages/core/src/gestures/__tests__/arenaTimersAndClaims.test.ts — clear
  • packages/core/src/gestures/__tests__/harness.ts — clear
  • packages/core/src/gestures/types.ts — clear
  • packages/core/src/hooks/usePager.test.ts — clear
  • packages/core/src/motion/README.md — clear
  • packages/core/src/motion/uikit/contextMenu.ts — clear
  • packages/core/src/privateAttributes/contextMenuTrigger.stylex.ts — clear
  • scripts/shared-identity.baseline.json — clear

Automated review (maintainer link)

Comment on lines +1010 to +1011
// The browser's own long-press menu (Android Chrome) for a finger the
// recognizer is timing, or will time once the touch layer loads: the

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 (INV29): this 28-word sentence carries two topics. Suggested:

// Android Chrome opens its own long-press menu. The recognizer decides for a
// finger it times, or will time after the layer loads.

This branch was successfully deployed

1 active deployment
Preview — 9c1cd2b9 Deployed Nov 15, 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) ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) CLA Signed This label is managed by the Meta Open Source bot. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants