Skip to content

fix(useMenuPress): a control a menu hosts beside its rows keeps its own press - #7305

Closed
vjeux wants to merge 1 commit into
meta:mainfrom
vjeux:menu-press-hosted-controls
Closed

vjeux wants to merge 1 commit into
meta:mainfrom
vjeux:menu-press-hosted-controls

Conversation

@vjeux

@vjeux vjeux commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

User impact

A form a menu hosts beside its rows goes dead. Under a finger a filter field does not focus and a checkbox does not toggle; with a mouse a "Create" button's click never arrives.

Problem and solution fit

  • Why it occurs: handleMenuPointerDown tracks every press whose nearest press root is the menu and cancels a finger's pointerdown. With no row under the release the gesture settles, and the stray-click swallower eats the control's click.
  • Why it harms the task: the control's own press is its only way to act, and the model has nothing to act on there.
  • Why it matters: DropdownMenu, ContextMenu and sub-menus all mount the model.

A press that begins on a form control, a link or an editable element outside every row is now the browser's. Rows, and controls inside rows, keep the model.

Expected behavior and authority

module:DropdownMenu/useMenuPress (current) ORD1 and ORD2 claim every press inside a menu. This PR amends ORD1 (proposed DEC-9): no root claims a press on a hosted control outside every row. Nothing else in the record changes. Because it amends a current record, it needs a spec owner's approval of this head.

Smallest restoration

handleMenuPointerDown returns before tracking when the target sits in an input, textarea, select, button, label, a[href], [contenteditable] or [role="textbox"] inside the menu and outside every row (any row role, or the caller's row selector). No API or default change.

Evidence

  • Before, in real Chromium on a new HostedControls story with main's hook: clicking the hosted "Create label" button leaves its counter at 0, and a finger tap on the hosted checkbox leaves it unchecked.
  • After: the counter reads 1, the checkbox checks, the menu stays open, and a mouse drag across rows still acts on the release.
  • Unchanged: the MenuPress and drill-in Chromium specs pass; a button inside a row still belongs to the row.
  • Out of scope: the menu's key handling still consumes typing in a hosted field, a separate gap.

Writing rubric results

R1 narration: ORD1 and DEC-9 are present tense; "Proposed" marks review state.
R2 research: none.
R3 evidence: the verification row names the tests.
R4 rejected alternatives: DEC-9 rejects a per-control opt-out attribute.
R5 change references: none.
R6 open questions: none.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

pnpm exec vitest run packages/core/src/hooks/useMenuPress.test.tsx packages/core/src/DropdownMenu/DropdownMenu.test.tsx \
  -t "controls the menu hosts|keep their own press"
  main's useMenuPress.ts: 3 failed, 1 passed (a button inside a row) · with the change: 4 passed

pnpm exec vitest run packages/core/src/DropdownMenu packages/core/src/ContextMenu packages/core/src/Selector \
  packages/core/src/hooks/useMenuPress.test.tsx packages/core/src/hooks/menuPressGesture.test.ts \
  packages/core/src/hooks/useLongPress.test.tsx packages/core/src/docPropLiterals.test.ts \
  packages/core/src/docPropReferences.test.ts --maxWorkers=8
  Test Files  13 passed (13)   Tests  559 passed (559)

pnpm storybook:build   (once with main's useMenuPress.ts for the red arm)
ASTRYX_STORYBOOK_DIR=<red build> pnpm exec playwright test \
  packages/core/src/DropdownMenu/__tests__/MenuHostedControls.a11y.chromium.spec.ts --project=chromium
  2 failed   (created: Received "0"; checkbox: Received unchecked)
pnpm exec playwright test MenuHostedControls MenuPress DropdownMenuDrillIn (.a11y.chromium.spec.ts) --project=chromium
  17 passed · MenuHostedControls --repeat-each=3: 6 passed

pnpm -F @astryxdesign/core typecheck, CI=true eslint, prettier --check, check:knowledge, check-changesets, check-sync   ✓

@vercel

vercel Bot commented Oct 10, 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 Oct 11, 2026 5:41pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 10, 2026
@astracat-bot

astracat-bot Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🔄 In progress (for maintainers only) Oct 11, 2026, 5:35 PM UTC

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Oct 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.9KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

25 of 448 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 754,077
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,188
Chat Full AI Chat probe light 155,733
Chat Full AI Chat probe dark 155,005
Chat Default neutral dark 33,205
Chat Default neutral light 32,876
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,229
Chat With Attachments probe dark 11,065
TableRowExpansion Detail Panel neutral dark 5,129
TableRowExpansion Detail Panel neutral light 4,050
SideNav Resizable in AppShell probe dark 3,208
TableGroupedRows Default neutral light 2,133
TableGroupedRows Default neutral dark 2,116
Markdown Default probe dark 897
Markdown Default probe light 897
Markdown Default neutral dark 882

and 5 more.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@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.

Thanks for the focused fix — leaving a hosted control's press with the browser is the right shape, and the evidence lines up: the hosted button and checkbox now act while the menu stays open, a hosted field's finger press is no longer cancelled, and controls inside rows still belong to the row.

Approval needs a maintainer/spec owner to update the existing spec first. Current ORD1 in module:DropdownMenu/useMenuPress claims every pointerdown inside a menu, and this change intentionally amends that claim through proposed DEC-9. What must be settled is whether no menu-press root should claim a press beginning on a form control, link, or editable element hosted outside every row, while a control inside a row of any state stays in the press model. Until a maintainer approves that amendment, this cannot be approved as conforming to the current spec; no code change is being requested for that reason alone.

No other concrete defect was found in the reviewed change. Keyboard typing inside a hosted field remains the separate existing gap already called out in this PR.

[Automated review]

@vjeux

vjeux commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 505f577

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Oct 11, 2026
…wn press

The press model tracked every press inside a menu as a row press: it
cancelled a finger's pointerdown and swallowed the click after the
release, so a field, button, checkbox or link a menu hosts outside its
rows went dead. A press that begins on a form control, a link or an
editable element outside every row is now left to the browser; rows, and
controls inside rows, keep the model. Amends ORD1 of
module:DropdownMenu/useMenuPress (proposed DEC-9), adds a HostedControls
story and a Chromium spec.
@vjeux
vjeux force-pushed the menu-press-hosted-controls branch from 505f577 to 0a30c86 Compare October 11, 2026 17:35
@vjeux

vjeux commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 0a30c86

@cixzhang cixzhang 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.

Owner ruling, cixzhang: a menu holds only menu items, so this exception should not exist.

role="menu" may contain only menuitem, menuitemcheckbox, menuitemradio, groups and separators. The HostedControls story puts a CheckboxInput and a Button directly inside the menu element, so a screen reader is told it is in a menu and then meets controls that are not menu items. Teaching the press model to step aside for them makes that structure work instead of fixing it.

What follows from that:

  • A control that is not a menu item belongs outside the role="menu" element, or the surface is a Popover rather than a menu. Outside the menu element, the press model never claims its presses, so the defect this PR fixes does not arise.
  • Drop the ORD1 amendment and DEC-9 from module:DropdownMenu/useMenuPress. ORD1 stays as it is.
  • If something inside the menu ever genuinely needs its own press, the handling belongs on the menu item, not on an exception list of hosted elements at the menu level.

No code in this PR should land.

@vjeux

vjeux commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the ruling. I'm following it and closing this PR: ORD1 stays as it is, and a control that is not a menu item goes outside the role="menu" element, or the surface becomes a Popover.

One place the ruling may reach: #7309 (merged today) is the keyboard counterpart of this exception. A text field or button placed beside a menu's rows keeps its own keys there, through hostedControlOf in DropdownMenu/menuItemRoles.ts and the caret guard the three menus now turn on. If the ruling covers that too, I'll open a PR that removes it.

@cixzhang

Copy link
Copy Markdown
Contributor

For reference: the replacement is #7344. header and footer on DropdownMenu hold controls in the popover, outside the role="menu" element, so the press model never claims them. #7338 removes #7309's keyboard counterpart before it ships.

This branch was successfully deployed

1 active deployment
Preview — 0a30c86c Deployed Oct 11, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants