Repository navigation
feat(DropdownMenu): a finger or a pen opens the menu as it presses - #8078
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
This pull request can't be approved yet: its main changes — the 150 ms finger hold-open (300 ms in a scroller) with a 13 px drift allowance, the 10 px handoff before the finger that opened a menu can pick, and the new public continueGesture — are not stated in any approved spec, because module:DropdownMenu/useMenuPress FR9 and DEC-4 are still proposed and still describe a 500 ms delay and the settle rule. An engineering owner needs to decide that direction, together with the new draft spec:AST-094, the touchOpen DEC-8 and the adaptive-query change measured against Selector DEC-1; once the module record carries the proposed text, an engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so if they are an engineering owner. Independently of that decision, please address:
- Land the four dependencies first, or base this pull request on their branch, so its diff is this change's own ~1,000-line commit rather than 24,416 lines.
useMenuPress.doc.mjsdocsDensestill says a finger never triggersonDismiss, which is no longer true withtouchOpen: 'press', and it lists neithertouchOpennorcontinueGesture.spec:AST-094FR7 proposes amendingspec:AST-090, which does not exist in the repository.
[Automated review]
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| DropdownMenuSubMenu | 72.6 kB (+539 B) · 9.7 kB CSS (0) | — | ✗ · ✓ · ✓ |
| DropdownMenu | 101.5 kB (+500 B) · 17.6 kB CSS (0) | — | ✗ · ✓ · ✓ |
| DropdownMenuCheckboxItem | 23.4 kB (0) · 6.6 kB CSS (0) | — | ✗ · ✓ · ✓ |
63 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| DropdownMenuDivider | 5.3 kB (0) · 548 B CSS (0) | — | ✗ · ✓ · — |
| DropdownMenuGroup | 6.4 kB (0) · 3.4 kB CSS (0) | — | ✗ · ✓ · — |
| DropdownMenuItem | 22.6 kB (0) · 6.3 kB CSS (0) | — | ✗ · ✓ · — |
| DropdownMenuRadioGroup | 6.6 kB (0) · 3.3 kB CSS (0) | — | ✗ · ✓ · — |
| DropdownMenuRadioItem | 23.4 kB (0) · 6.6 kB CSS (0) | — | ✗ · ✓ · — |
| NavHeadingMenu | 17.9 kB (+1012 B) · 3.5 kB CSS (0) | — | — · — · — |
| lab/CommentThread | 351.4 kB (+660 B) · 2.4 kB CSS (0) | — | — · — · — |
| lab/Comments | 358.2 kB (+647 B) · 2.5 kB CSS (0) | — | — · — · — |
| BreadcrumbItem | 89.3 kB (+570 B) · 12.1 kB CSS (0) | — | — · — · — |
| SideNavHeading | 80.1 kB (+559 B) · 11.3 kB CSS (0) | — | — · — · — |
| Markdown | 192.9 kB (+545 B) · 20.8 kB CSS (0) | — | — · — · — |
| TopNavMenu | 79.1 kB (+538 B) · 11.3 kB CSS (0) | — | — · — · — |
| ContextMenu | 112.6 kB (+534 B) · 17.5 kB CSS (0) | — | — · — · — |
| PowerSearch | 298.1 kB (+532 B) · 24.5 kB CSS (0) | — | — · — · — |
| TopNavHeading | 79.7 kB (+528 B) · 11.3 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditorToolbar | 283.9 kB (+528 B) · 454 B CSS (0) | — | — · — · — |
| TableHeaderCell | 113.4 kB (+521 B) · 17.7 kB CSS (0) | — | — · — · — |
| TabMenu | 76.4 kB (+515 B) · 11.2 kB CSS (0) | — | — · — · — |
| TableCell | 113.9 kB (+511 B) · 18.0 kB CSS (0) | — | — · — · — |
| MoreMenu · Storybook | 101.8 kB (+503 B) · 17.6 kB CSS (0) | 91 (0) | ✓ · ✓ · ✓ |
| Table | 129.8 kB (+503 B) · 18.4 kB CSS (0) | — | — · — · — |
| Pagination | 115.0 kB (+479 B) · 17.8 kB CSS (0) | — | — · — · — |
| Selector | 104.8 kB (+449 B) · 17.5 kB CSS (0) | — | — · — · — |
| lab/TabBar | 82.1 kB (+227 B) · 1.8 kB CSS (0) | — | — · — · — |
| lab/ChatVirtualizer | 55.9 kB (+124 B) · 223 B CSS (0) | — | — · — · — |
| lab/Schedule | 109.6 kB (+84 B) · 3.9 kB CSS (0) | — | — · — · — |
| Switch | 106.6 kB (+13 B) · 10.0 kB CSS (0) | — | — · — · — |
| lab/NavigationScreen | 83.5 kB (+11 B) · 1.5 kB CSS (0) | — | — · — · — |
| lab/NavigationStack | 83.5 kB (+11 B) · 1.5 kB CSS (0) | — | — · — · — |
| AlertDialog | 108.9 kB (0) · 14.6 kB CSS (0) | — | — · — · — |
| BaseTypeahead | 76.3 kB (0) · 11.0 kB CSS (0) | — | — · — · — |
| BottomSheet | 69.4 kB (0) · 7.7 kB CSS (0) | — | — · — · — |
| ButtonGroup | 43.5 kB (0) · 3.7 kB CSS (0) | — | — · — · — |
| ChatComposer | 82.5 kB (0) · 12.1 kB CSS (0) | — | — · — · — |
| ChatComposerInput | 80.2 kB (0) · 11.3 kB CSS (0) | — | — · — · — |
| ChatComposerTokenElement | 80.2 kB (0) · 11.3 kB CSS (0) | — | — · — · — |
| ComplexSelector | 75.4 kB (0) · 11.9 kB CSS (0) | — | — · — · — |
| DateInput | 192.3 kB (0) · 17.1 kB CSS (0) | — | — · — · — |
| DateRangeInput | 97.0 kB (0) · 12.5 kB CSS (0) | — | — · — · — |
| DateTimeInput | 214.5 kB (0) · 18.8 kB CSS (0) | — | — · — · — |
| Lightbox | 125.8 kB (0) · 10.6 kB CSS (0) | — | — · — · — |
| MultiSelector | 99.2 kB (0) · 16.9 kB CSS (0) | — | — · — · — |
| Popover | 95.0 kB (0) · 14.3 kB CSS (0) | — | — · — · — |
| ResizeHandle | 22.2 kB (0) · 4.3 kB CSS (0) | — | — · — · — |
| SegmentedControl | 99.5 kB (0) · 6.9 kB CSS (0) | — | — · — · — |
| SideNav | 118.0 kB (0) · 11.4 kB CSS (0) | — | — · — · — |
| SideNavItem | 74.8 kB (0) · 11.2 kB CSS (0) | — | — · — · — |
| Slider | 112.1 kB (0) · 8.8 kB CSS (0) | — | — · — · — |
| TimeInput | 167.2 kB (0) · 16.1 kB CSS (0) | — | — · — · — |
| Toast | 101.0 kB (0) · 10.3 kB CSS (0) | — | — · — · — |
| ToggleButton | 89.8 kB (0) · 10.1 kB CSS (0) | — | — · — · — |
| ToggleButtonGroup | 40.7 kB (0) · 3.7 kB CSS (0) | — | — · — · — |
| Tokenizer | 101.2 kB (0) · 19.2 kB CSS (0) | — | — · — · — |
| TopNavMegaMenu | 74.0 kB (0) · 11.9 kB CSS (0) | — | — · — · — |
| Typeahead | 85.5 kB (0) · 12.5 kB CSS (0) | — | — · — · — |
| lab/ChatEmojiPicker | 110.3 kB (0) · 773 B CSS (0) | — | — · — · — |
| lab/ChatReactionBar | 111.4 kB (0) · 1.1 kB CSS (0) | — | — · — · — |
| lab/CommentComposer | 156.0 kB (0) · 1.9 kB CSS (0) | — | — · — · — |
| lab/PageControl | 76.6 kB (0) · 709 B CSS (0) | — | — · — · — |
| lab/TabBarItem | 3.9 kB (0) · 1.8 kB CSS (0) | — | — · — · — |
| lab/TourStep | 101.3 kB (0) · 590 B CSS (0) | — | — · — · — |
| lab/TransferListSelector | 114.0 kB (0) · 1.4 kB CSS (0) | — | — · — · — |
| ContextMenuItem | 32.9 kB (−5 B) · 6.3 kB CSS (0) | — | — · — · — |
Visual changes: 4 snapshots in 1 component
A change is a question for the reviewer, not a failure.
Package size: @astryxdesign/core 7.34 MB packed (+4.0 kB); no new dependencies.
API changes: core +0 · ~2 · −0
2 API changes (advisory)
| Package | Where | Signature | Usage | |
|---|---|---|---|---|
| ~ | core |
. · Hooks · hook useMenuPress |
hook useMenuPress: (options: UseMenuPressOptions) => UseMenuPressReturn → hook useMenuPress: (input: UseMenuPressOptions) => UseMenuPressReturn |
import {useMenuPress} from '@astryxdesign/core'; useMenuPress(…) |
| ~ | core |
. · Types · interface UseMenuPressOptions |
longPressDelayMs?: number = 500 → longPressDelayMs?: number |
import type {UseMenuPressOptions} from '@astryxdesign/core'; const x: UseMenuPressOptions = {longPressDelayMs: …} |
Touched components checked; add ci:run-visual or ci:run-rtl to run the full suites.
Generated by PR Enrichment workflow | View full report
3d6b786 to
6b1e606
Compare
There was a problem hiding this comment.
This pull request can't be approved yet: its main changes — the 150 ms finger hold-open (300 ms in a scroller), the 10 px handoff before the finger that opened a menu can pick, the cleared highlight after a cancelled press and the new public continueGesture — are not stated in any approved spec, because module:DropdownMenu/useMenuPress FR9 and DEC-4 are still proposed and still describe a 500 ms hold and the settle rule. An engineering owner needs to settle that direction, together with the draft spec:AST-094, touchOpen (DEC-8) and the adaptive sheet query measured against Selector DEC-1; once the module record carries the proposed text, an engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request, and the author, as an engineering owner, may do so. Independently of that decision, please address:
- Land the four dependencies first, or base this pull request on their branch, so its diff is this change's own ~1,060-line commit rather than 26,635 lines.
.changeset/menu-press-uimenu.mdshould name the old 500 mslongPressDelayMsdefault and how to keep it, and say that the hook adds 150 ms to a caller's own value inside a scroller.useMenuPress.doc.mjsdocsDensestill says a finger never triggersonDismiss, and it lists neithertouchOpennorcontinueGesture.spec:AST-094FR7 proposes amendingspec:AST-090, which does not exist in the repository.
[Automated review]
|
Posted by Cindy's agent on her behalf. Parts of this PR re-implement behavior that already exists, or is being specified, as a shared part of core. Converging keeps one implementation per behavior:
This is about where the behavior lives, not about the PR's intent. |
|
Agreed: one implementation.
|
6b1e606 to
309b4eb
Compare
|
/approve-spec c3bfa08 |
Under a finger or a pen, a DropdownMenu or MoreMenu trigger opens its menu as it is pressed, instead of after a 500 ms hold (spec:AST-094 FR29, FR43). Inside a scroll view it opens once the 150 ms content-touch delay passes with no scroll, so a scroll that starts on the trigger still scrolls. The finger that opened the menu picks a row only after moving 10 px. presentation="popover" keeps the previous behavior. useMenuPress with no longPressDelayMs follows the same rules, and longPressDelayMs: 500 keeps the previous hold.
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet. A finger or a pen now opens a DropdownMenu or MoreMenu as it presses (after the 150 ms content-touch delay inside a scroll view), the public useMenuPress with no longPressDelayMs follows the same rule, and presentation="popover" or longPressDelayMs: 500 keeps the released behavior, as spec:AST-094 FR25, FR29 and FR43 state.
Next: mark the pull request ready for review, and a maintainer adds the ci:run label so CI runs on this fork branch.
Non-blocking:
useMenuPress.doc.mjssays the press opens the menu "on a touch screen" and never mentions a pen, while the hook opens on press for any touch or pen pointer on every device, as the changeset says.
[Automated review]
|
/approve-spec 75391ad |
There was a problem hiding this comment.
Requesting changes. The press itself follows spec:AST-094 FR29: under a finger or a pen, an anchored DropdownMenu or MoreMenu now opens as its trigger is pressed (after the 150 ms content-touch delay inside scrolling content), the opening finger picks only past the 10 px handoff, a mouse is unchanged, and presentation="popover" or longPressDelayMs: 500 keeps the released behavior.
Blocking
- Miss:
.changeset/menu-press-uimenu.md(and the description's public delta) says every DropdownMenu and MoreMenu trigger now opens on press, but a menu shown as a bottom sheet (presentation="bottom-sheet", oradaptiveon a compact touch screen) still opens at the tap's click, so the release note should name the anchored menu only.
Non-blocking
useMenuPress.doc.mjsstill says the press opens the menu "on a touch screen" and names only a finger, while the hook opens on press for any touch or pen pointer on every device.
Next: fix the changeset wording, then mark the pull request ready for review so CI runs; every job was skipped on this draft head. #8508 is based on an earlier commit of this branch, so it needs restacking onto this head before the Stack: line holds.
[Automated review]
A menu shown as a bottom sheet still opens at the tap's click, so the release note names the anchored menu, as the press does. The hook's doc names a finger or a pen on every device, as the hook acts.
A raw page that scrolls with the document. Its Actions menu sits in a fixed top bar, so it opens as a finger presses it, and a slide onto a row runs that row once. Its More menu sits in the page, so a flick that starts on it scrolls the page. The bar shows which row ran and how many times.
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet, since every job was skipped on the draft. Under a finger or a pen, an anchored DropdownMenu or MoreMenu now opens as its trigger is pressed (after the 150 ms content-touch delay inside scrolling content), useMenuPress with no longPressDelayMs follows the same rule, and presentation="popover" or longPressDelayMs: 500 keeps the released behavior, as spec:AST-094 FR25 and FR29 state. The release note now names the anchored menu only, which fixes the last review's blocking point.
Next: mark the pull request ready for review, and a maintainer adds the ci:run label so CI runs on this fork branch. #8508 sits on an earlier commit of this branch, so it needs restacking onto this head before its Stack: line holds.
Non-blocking:
- Miss:
menuPressValues.tsadds a secondDELAYS_CONTENT_TOUCHES_MS, whilemotion/uikit/scroll.tsalready exports that constant on its own for the press clocks; importing it there drops the copy and its sync test line. - Miss: the comment above
longPressApiRefinuseMenuPress.tsstill says the detector hook is created in that file afterfireLongPress; both now live inmenuTriggerPress.ts.
[Automated review]
|
/approve-spec a71e804 |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet, since every job was skipped on the draft.
Under a finger or a pen, an anchored DropdownMenu or MoreMenu trigger now opens as it is pressed, and 150 ms after the press inside scrolling content, as spec:AST-094 FR29 states; useMenuPress with no longPressDelayMs follows the same rule (FR25), and longPressDelayMs: 500 or presentation="popover" keeps the released hold. The new DropdownMenu cases fail on main and pass here, and a mouse is unchanged.
Two optional cleanups from the last review still stand: import DELAYS_CONTENT_TOUCHES_MS from motion/uikit/scroll.ts instead of keeping a copy in menuPressValues.ts, and update the comment above longPressApiRef in useMenuPress.ts, which still says the detector is created in that file.
|
/approve-spec 3b7e253 |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet; every job was skipped while the pull request is a draft, and it runs once it is marked ready for review.
Under a finger or a pen, the trigger of an anchored DropdownMenu or MoreMenu now opens its menu as it is pressed, and after the 150 ms content-touch delay inside scrolling content, as spec:AST-094 FR29 requires. useMenuPress with no longPressDelayMs follows the same rule (FR25). presentation="popover" and longPressDelayMs: 500 keep the released hold. The new cases fail on main and pass here. In Chromium with touch, the menu opens 2 ms after the press, or 153 ms after it on a page that scrolls; a mouse is unchanged.
Non-blocking comment fixes:
- Regression:
motion/uikit/gestures.ts:256-259says the press model reads a copy ofholdOpenSlopinhooks/menuPressValues.ts, but that file now copies onlyhandoff; the drift allowance isMENU_PRESS_TRIGGER_DRIFT_PXinuseMenuPress.ts. useMenuPress.ts:80-84describesMENU_PRESS_LONG_PRESS_MSfor "the 'pointer' touch model and nolongPressDelayMs", which the hook no longer produces.useMenuPress.ts:108-110explains the trigger context by a hook argument that no longer exists, now that the trigger half lives inuseMenuPress.
| * `holdOpenSlop`: how far a finger on the button may drift and still open | ||
| * the menu. `handoff`: how far the finger that opened it travels before it | ||
| * picks. The menu press model reads copies of them in | ||
| * `hooks/menuPressValues.ts`. |
There was a problem hiding this comment.
Regression (non-blocking): hooks/menuPressValues.ts now copies only handoff. The drift allowance the hook uses is MENU_PRESS_TRIGGER_DRIFT_PX = 13 in useMenuPress.ts:93, and no test ties it to holdOpenSlop since MENU_PRESS_HOLD_OPEN_SLOP_PX and its test line were removed. Perhaps: "The menu press model reads a copy of handoff in hooks/menuPressValues.ts; holdOpenSlop matches MENU_PRESS_TRIGGER_DRIFT_PX in hooks/useMenuPress.ts." Or restore that copy and its test line.
| * How long a finger rests on the trigger before the menu opens under it, | ||
| * with the 'pointer' touch model and no `longPressDelayMs`. A tap released | ||
| * sooner opens the menu through the trigger's click. |
There was a problem hiding this comment.
Non-blocking: the hook no longer runs the pointer model without a longPressDelayMs (the pointer model now means a delay was set, line 383). Perhaps: "The released finger hold. DropdownMenu passes it for presentation="popover"; a caller keeps it by passing longPressDelayMs: 500."
| // The model's own state changes through these calls, never through a | ||
| // write to one of its refs. React Compiler reads a write through a hook | ||
| // argument as mutating it. |
There was a problem hiding this comment.
Non-blocking (INV29): the trigger half moved back into useMenuPress, so this context is no longer a hook argument. MenuTriggerContext, installRef, attachRef and holdDetectorsRef now only route calls inside one function. Calling the refs directly would drop them; otherwise this comment should give the reason the indirection still has.
|
/approve-spec 3b7e253 |
|
Decision: D-20261111-245 |
There was a problem hiding this comment.
Approved. Under a finger or a pen, the trigger of an anchored DropdownMenu or MoreMenu now opens its menu as it is pressed, and after the 150 ms content-touch delay inside scrolling content, as spec:AST-094 FR29 requires; useMenuPress with no longPressDelayMs follows the same rule (FR25), and presentation="popover" or longPressDelayMs: 500 keeps the released hold. The new cases fail on main and pass here, CI passes on this head, and in Chromium with touch the menu opens 3 ms after the press, or 152 ms after it on a page that scrolls, while a mouse is unchanged.
Three non-blocking comment fixes from the earlier review still apply (motion/uikit/gestures.ts:255-260, hooks/useMenuPress.ts:80-84 and :108-110); they are on the open inline threads.
|
/approve-spec cab4595 |
|
Decision: D-20261111-256 |












Stack: #9764 → #9769 → #8485 and #8080; #8078 → #8508 and #8080.
Behavior module: useMenuPress
User need
Under a finger or a pen, a DropdownMenu or MoreMenu opened only at a tap's lift or after a 500 ms hold. On iOS a pull-down menu opens on the press, so the finger slides straight to a row.
Problem and solution fit
An anchored menu's trigger now opens on the press, on every device (
spec:AST-094FR29, FR43). In a scroll view it first waits UIKit's 150 ms content-touch delay; a drift over 13 px in that time scrolls instead. The finger that opened the menu then picks only after the 10 px handoff.useMenuPresswith nolongPressDelayMsfollows the same rules (FR25).Current specification
spec:AST-094FR25, FR26–FR30 and FR43, andmodule:DropdownMenu/useMenuPress(current). Thecomponent:DropdownMenurecord closes FR8's finger gap, in text only.Public delta and caller burden
presentation="popover"keeps the tap's lift and the 500 ms hold. A bottom sheet and a mouse are unchanged.useMenuPress'slongPressDelayMsgoes from 500 ms to unset, so a finger opens on the press, with the same handoff.longPressDelayMs: 500keeps the previous hold.Design and alternatives
Evidence
Writing rubric results
R1 narration, R2 research, R4 rejected alternatives, R5 change references, R6 open questions: none. R3 evidence: FR8's verification row names the press and tap cases, not the hold.
Scope
Components: DropdownMenu, MoreMenu, useMenuPress
Testing
At cab4595: 3b7e253 with main f27380a merged in, its own lines unchanged. 3b7e253 is a71e804 plus one commit, so every menu calls the one
useMenuPress, as on main. a71e804 is 7419b9d with main ebb9dde merged in. 7419b9d is d08f0d3 with the text fix and a sandbox page. On the sandbox page/pages/menu-press-cases/, which scrolls, with touch emulation:A device run at this head is pending.
At cab4595, the ui project (24,377), the Node project (19,114), the core type check, strict ESLint,
pnpm check:knowledgeandpnpm review:prepass. This commit changes no spec, and the interaction counts equal a71e804's. The DropdownMenu, motion, Layer, nav and Popover interaction specs pass in Chromium: 318 pass, 16 skip. In WebKit's CI container at one worker: 239 pass, 95 skip. The accessibility specs of those menus, ContextMenu and Selector pass in Chromium (391), and the browser ones in WebKit (19).Earlier gates, at 7419b9d: the core units (21,435), the core type check, strict ESLint, the touch-bundle test (11),
pnpm check:knowledgeandpnpm review:prepass. At c3bfa08, the 33 browser specs that open the menu, nav and tab stories passed in Chromium (200). They passed in WebKit's CI container too (54, with 29 engine skips). 7419b9d changes only the scroll-view helper and the nav menus' hook. At it, the touch-press spec (7) and the focus-ring and press audits (17) pass in Chromium. At the first merge (e8face7), the menu, nav and picker units (1,745) and the touch-bundle test (11) passed.Public and internal API delta
UseMenuPressOptions.longPressDelayMsgoes from 500 ms to unset. Unset follows UIMenu, so a finger opens the menu as it presses.spec:AST-094FR25, FR29, FR43).useMenuPress({menuRef, itemSelector});useMenuPress({menuRef, itemSelector, longPressDelayMs: 500})keeps the released wait.useDropdownMenuPressand its typesDropdownMenuPressOptionsandDropdownMenuPressReturn. DropdownMenu callsuseMenuPress, as every other menu does.useMenuPress({menuRef, triggerRef, itemSelector, longPressDelayMs: isPopover ? 500 : undefined}).