Skip to content

fix(Layer): a layer opened by a right click stays open when that press is released - #10128

Merged
cixzhang merged 11 commits into
mainfrom
fix/6947-contextmenu-release
Nov 8, 2026
Merged

cixzhang merged 11 commits into
mainfrom
fix/6947-contextmenu-release

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #6947.

User impact

A person who right-clicks an element that opens a light-dismissible layer from its contextmenu event sees the layer flash and close as soon as they let go of the mouse button. The common case is a DropdownMenu opened through isMenuOpen from a right click on a nearby element, as in the issue. With this fix the menu stays open after that release and closes on the person's next press outside, as a context menu does.

Problem and solution fit

  • Why does it close? Light-dismissible layers are popover="auto". The browser's light dismiss runs at each pointerup, and a release outside every open popover reads as a dismissal. The press that opened the layer started before the layer existed, so its own release lands outside it.
  • Why does that harm the task? The person never reaches the menu, so the right-click affordance does nothing.
  • Why does it matter? The opening press both opens and closes the layer. spec:AST-003 FR11–FR13 state that one physical gesture cannot do both, whatever the browser's event order.

The fix gives that press to the layer. When a light-dismissible layer shows while a press that fired contextmenu is still down, the layer captures that pointer while it is outside the layer, so a release there lands on the layer and light dismiss leaves it open. Over the layer the capture lets go, so the held pointer still highlights a menu's rows, and a release there is inside the layer anyway. The claim ends at that press's release. Calling preventDefault on the pointerup does not stop Chromium's light dismiss (checked in real Chromium), so pointer capture is the lever. The tests use a mouse right click. The same path applies to any press that is still down when it fires contextmenu (Android Chrome's long press is one); iOS Safari fires no contextmenu from a long press.

Expected behavior and authority

  • spec:AST-003 FR11–FR13: pointer dismissal goes by gesture identity, and the gesture that opens a layer does not also close it. This PR adds one AST-003 verification row for FR11–FR13 that names the context-menu press case (Specs & Decisions asked for this row).
  • The issue's own expectation: "the menu stays open, as a context menu does."

Smallest restoration

  • Layer/gestureCounter.ts already counts gestures for FR11–FR13. It now also records the pointer of the press in flight and whether that press fired contextmenu, through the shared input stream (subscribeInput). A new claimContextMenuPress(layer) captures that pointer to the layer while it is outside the layer, until the press's release or until the layer closes. A move reads no layout: the claim reads the layer's box, and the box of each popover open in it, once, and again only after a scroll, a resize or a toggle in the layer (scroll and resize come through the shared input stream). A layer inside an open shadow root works too.
  • Layer/useLayer.tsx: show() makes that one call for a light-dismissible layer, right after the browser accepts the show.
  • No new API, no change to manual popovers or to outsidePress.ts, and nothing for a primary-button press. DropdownMenu's own trigger press keeps its invoker hold.

Interaction with the entrance input hold in the Popover stack (#8223): that hold ignores new taps while a touch entrance plays. This claim only affects the one press that opened the layer, and only its release target. Where a finger's long press fires contextmenu and opens a Popover, that finger releases on the Popover instead of outside it. The hold has nothing to ignore there, because that release is not a new tap. A tap that comes later during the entrance is a new gesture, so the hold handles it as it does now. The two do not touch the same event, and the useLayer change is one call so that stack rebases simply.

Evidence

  • Reproduction before the change (real Chromium, same build, claim disabled): 3 of 3 cases fail. The layer and the DropdownMenu are hidden right after the right button's release.
  • Result after the change (real Chromium): 12 of 12 pass (4 cases, --repeat-each=3). The layer and the DropdownMenu stay open after the release, also when the release lands 60 px away from the zone, and a later click outside closes both. With the right button still down, moving onto the DropdownMenu focuses the row under the pointer; with a capture that never lets go (the earlier head), that case fails.
  • On this head the 4 cases pass again in real Chromium (Storybook built from this head).
  • Representative unchanged path on this head: 131 behavior cases in the Layer, DropdownMenu and ContextMenu Chromium specs pass. MenuPress's touch-slide case fails with this branch's older copy of that spec and passes with main's current copy (13 of 13), which is the copy CI runs from the merge ref. The 8 visual audit specs need a git checkout and were not run in that environment; CI runs them.
  • Regression tests:
    • useLayer.test.tsx: a layer shown from a context-menu press captures that press's pointer; over the layer the capture lets go, outside it takes the pointer again, another pointer's move changes nothing, and the release ends the claim. gestureCounter.test.ts: the claim lets go over the layer's box and holds outside it, reading the box once; it reads it again after a scroll; it works in an open shadow root; and a layer that closes while the button is down lets the pointer go and ends the claim. A keyboard context menu (Shift+F10, no press) and a layer without light dismiss capture nothing. The first test fails without the show() call.
    • Layer/__tests__/LayerContextMenuPress.a11y.browser.spec.ts (Chromium and WebKit projects): the real-engine cases above, on the new Core/Layer ContextMenuPressOpensALayer story.

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

  • vitest run packages/core/src/Layer packages/core/src/DropdownMenu packages/core/src/Popover packages/core/src/ContextMenu packages/core/src/Tooltip
  • playwright test --project=chromium packages/core/src/Layer/__tests__/LayerContextMenuPress.a11y.browser.spec.ts against a Storybook built from this head (right-button press and release, on and off the zone; a later click outside).

Writing rubric results

R1 narration: none; the new verification row states the check and its failure in the present tense.
R2 research: none in the record; the Chromium preventDefault check lives in this description.
R3 evidence: the row names the unit and real-Chromium checks that verify it.
R4 rejected alternatives: none in the record.
R5 change references: none.
R6 open questions: none.

Stack: #10128 → #10689

…s is released

A light-dismissible layer that shows from a contextmenu event captures
that press's pointer, so its release lands on the layer and the
browser's light dismiss leaves it open. A later press outside still
dismisses it (spec:AST-003 FR11-FR13).

Fixes #6947
@vercel

vercel Bot commented Nov 5, 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 8, 2026 7:26pm UTC

Request Review

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

astracat-bot Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 8, 2026, 7:41 PM UTC

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

cixzhang commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 97e2aaf

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

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · d8761e6

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
LayerProvider 4.2 kB (0) · 20 B CSS (0) — ✓ · ✓ · ✗
TopNavHeading 74.9 kB (+520 B) · 11.1 kB CSS (0) — — · — · —
SideNavHeading 75.5 kB (+495 B) · 11.3 kB CSS (0) — — · — · —
115 more components
Component Size LoC Visual · A11y · RTL
ListItem 69.9 kB (+490 B) · 11.4 kB CSS (0) — — · — · —
TextArea 62.3 kB (+484 B) · 9.3 kB CSS (0) — — · — · —
Tokenizer 91.3 kB (+473 B) · 18.8 kB CSS (0) — — · — · —
DateInput 184.3 kB (+472 B) · 17.0 kB CSS (0) — — · — · —
ComplexSelector 70.9 kB (+471 B) · 11.8 kB CSS (0) — — · — · —
DateTimeInput 205.9 kB (+470 B) · 18.7 kB CSS (0) — — · — · —
RadioList 56.2 kB (+469 B) · 7.3 kB CSS (0) — — · — · —
Slider 107.2 kB (+469 B) · 8.8 kB CSS (0) — — · — · —
TopNavMenu 74.5 kB (+468 B) · 11.2 kB CSS (0) — — · — · —
InputGroup 56.5 kB (+467 B) · 7.8 kB CSS (0) — — · — · —
FieldLabel 51.0 kB (+465 B) · 5.7 kB CSS (0) — — · — · —
SideNavItem 70.4 kB (+465 B) · 11.1 kB CSS (0) — — · — · —
ChatLayoutScrollButton 60.7 kB (+464 B) · 10.2 kB CSS (0) — — · — · —
ChatToolCalls 31.8 kB (+464 B) · 8.3 kB CSS (0) — — · — · —
Button 60.2 kB (+463 B) · 10.0 kB CSS (0) — — · — · —
TabList 43.8 kB (+463 B) · 6.5 kB CSS (0) — — · — · —
ChatDictationButton 60.7 kB (+462 B) · 10.0 kB CSS (0) — — · — · —
SegmentedControl 93.9 kB (+461 B) · 6.9 kB CSS (0) — — · — · —
lab/TourStep 95.3 kB (+460 B) · 590 B CSS (0) — — · — · —
Spinner 24.5 kB (+459 B) · 6.2 kB CSS (0) — — · — · —
Field 54.8 kB (+456 B) · 7.2 kB CSS (0) — — · — · —
SideNavCollapseButton 61.0 kB (+456 B) · 10.0 kB CSS (0) — — · — · —
Timer 13.8 kB (+456 B) · 6.0 kB CSS (0) — — · — · —
lab/ChatEmojiPicker 103.6 kB (+456 B) · 773 B CSS (0) — — · — · —
ChatSendButton 60.6 kB (+455 B) · 10.0 kB CSS (0) — — · — · —
CommandPaletteInput 31.5 kB (+455 B) · 7.5 kB CSS (0) — — · — · —
TableCell 108.9 kB (+455 B) · 17.8 kB CSS (0) — — · — · —
IconButton 60.2 kB (+454 B) · 10.0 kB CSS (0) — — · — · —
lab/CommentComposer 148.7 kB (+454 B) · 1.9 kB CSS (0) — — · — · —
Carousel 69.8 kB (+453 B) · 10.9 kB CSS (0) — — · — · —
ChatMessageList 27.9 kB (+452 B) · 7.0 kB CSS (0) — — · — · —
richtext/RichTextEditor 296.9 kB (+452 B) · 2.6 kB CSS (0) — — · — · —
BreadcrumbItem 84.5 kB (+451 B) · 12.1 kB CSS (0) — — · — · —
MobileNavToggle 60.5 kB (+451 B) · 10.0 kB CSS (0) — — · — · —
StatusDot 31.2 kB (+450 B) · 5.3 kB CSS (0) — — · — · —
lab/DialogHeroHeader 82.9 kB (+450 B) · 372 B CSS (0) — — · — · —
Timestamp 32.7 kB (+449 B) · 10.3 kB CSS (0) — — · — · —
Typeahead 79.6 kB (+449 B) · 12.4 kB CSS (0) — — · — · —
lab/CommentPin 57.1 kB (+448 B) · 1.2 kB CSS (0) — — · — · —
AppShell 90.8 kB (+447 B) · 13.5 kB CSS (0) — — · — · —
TableHeaderCell 108.4 kB (+445 B) · 17.6 kB CSS (0) — — · — · —
charts/ChartTooltip 176.8 kB (+444 B) · 423 B CSS (0) — — · — · —
FileInput 69.1 kB (+443 B) · 10.9 kB CSS (0) — — · — · —
Text 11.6 kB (+443 B) · 5.4 kB CSS (0) — — · — · —
Toolbar 43.7 kB (+443 B) · 8.1 kB CSS (0) — — · — · —
DropdownMenu 96.8 kB (+442 B) · 17.6 kB CSS (0) — — · — · —
NumberInput 71.7 kB (+442 B) · 11.4 kB CSS (0) — — · — · —
ChatComposer 77.8 kB (+441 B) · 12.0 kB CSS (0) — — · — · —
lab/EmojiPicker 86.2 kB (+441 B) · 751 B CSS (0) — — · — · —
lab/LineClamp 13.8 kB (+441 B) · 168 B CSS (0) — — · — · —
TopNavMegaMenu 69.6 kB (+439 B) · 11.8 kB CSS (0) — — · — · —
Tooltip 29.5 kB (+438 B) · 4.4 kB CSS (0) — — · — · —
ChatLayout 80.9 kB (+437 B) · 10.5 kB CSS (0) — — · — · —
Toast 98.1 kB (+437 B) · 10.3 kB CSS (0) — — · — · —
ContextMenu 107.6 kB (+436 B) · 17.4 kB CSS (0) — — · — · —
DropdownMenuSubMenu 70.0 kB (+436 B) · 9.7 kB CSS (0) — — · — · —
MoreMenu 97.1 kB (+436 B) · 17.6 kB CSS (0) — — · — · —
richtext/RichTextView 275.9 kB (+436 B) · 2.3 kB CSS (0) — — · — · —
lab/DiffViewer 86.6 kB (+435 B) · 2.1 kB CSS (0) — — · — · —
lab/ListInput 101.7 kB (+435 B) · 1.6 kB CSS (0) — — · — · —
CheckboxList 69.3 kB (+433 B) · 8.2 kB CSS (0) — — · — · —
InfoTip 46.6 kB (+433 B) · 5.3 kB CSS (0) — — · — · —
charts/ChartLegend 49.0 kB (+432 B) · 224 B CSS (0) — — · — · —
DialogHeader 63.0 kB (+432 B) · 11.5 kB CSS (0) — — · — · —
Heading 12.2 kB (+432 B) · 5.4 kB CSS (0) — — · — · —
Popover 89.0 kB (+432 B) · 14.2 kB CSS (0) — — · — · —
lab/ChatReactionBar 104.7 kB (+432 B) · 1.1 kB CSS (0) — — · — · —
Banner 62.2 kB (+430 B) · 10.5 kB CSS (0) — — · — · —
Switch 101.7 kB (+430 B) · 9.9 kB CSS (0) — — · — · —
TableSelectionToolbar 70.4 kB (+430 B) · 13.2 kB CSS (0) — — · — · —
HoverCard 27.5 kB (+429 B) · 4.4 kB CSS (0) — — · — · —
TimeInput 159.8 kB (+429 B) · 16.0 kB CSS (0) — — · — · —
TabMenu 71.7 kB (+427 B) · 11.1 kB CSS (0) — — · — · —
CodeBlock 74.9 kB (+426 B) · 11.3 kB CSS (0) — — · — · —
Lightbox 120.4 kB (+426 B) · 10.6 kB CSS (0) — — · — · —
CheckboxListItem 70.9 kB (+425 B) · 11.4 kB CSS (0) — — · — · —
ChatComposerInput 75.5 kB (+424 B) · 11.3 kB CSS (0) — — · — · —
ChatComposerTokenElement 75.5 kB (+424 B) · 11.3 kB CSS (0) — — · — · —
DrawerHeader 63.2 kB (+423 B) · 12.9 kB CSS (0) — — · — · —
Stepper 61.8 kB (+423 B) · 10.1 kB CSS (0) — — · — · —
AvatarGroupOverflow 48.8 kB (+420 B) · 5.6 kB CSS (0) — — · — · —
Link 53.0 kB (+417 B) · 7.0 kB CSS (0) — — · — · —
Calendar 71.2 kB (+416 B) · 10.6 kB CSS (0) — — · — · —
DateRangeInput 92.3 kB (+415 B) · 12.5 kB CSS (0) — — · — · —
Pagination 109.5 kB (+414 B) · 17.8 kB CSS (0) — — · — · —
Selector 99.4 kB (+414 B) · 17.4 kB CSS (0) — — · — · —
charts/Chart 199.4 kB (+413 B) · 494 B CSS (0) — — · — · —
Table 117.8 kB (+413 B) · 18.2 kB CSS (0) — — · — · —
lab/Schedule 105.7 kB (+413 B) · 3.9 kB CSS (0) — — · — · —
lab/Comments 341.3 kB (+412 B) · 2.5 kB CSS (0) — — · — · —
SideNav 112.1 kB (+411 B) · 11.4 kB CSS (0) — — · — · —
lab/SelectableCardGroup 64.3 kB (+411 B) · 162 B CSS (0) — — · — · —
lab/TransferListSelector 114.3 kB (+411 B) · 1.9 kB CSS (0) — — · — · —
RadioListItem 67.2 kB (+410 B) · 10.1 kB CSS (0) — — · — · —
Avatar 43.1 kB (+409 B) · 5.5 kB CSS (0) — — · — · —
BaseTypeahead 71.0 kB (+408 B) · 10.9 kB CSS (0) — — · — · —
AvatarGroup 45.9 kB (+407 B) · 5.7 kB CSS (0) — — · — · —
TextInput 67.6 kB (+406 B) · 11.2 kB CSS (0) — — · — · —
Thumbnail 64.5 kB (+404 B) · 11.6 kB CSS (0) — — · — · —
CommandPalette 73.1 kB (+401 B) · 12.7 kB CSS (0) — — · — · —
PowerSearch 284.0 kB (+401 B) · 24.2 kB CSS (0) — — · — · —
TopNav 72.2 kB (+401 B) · 10.9 kB CSS (0) — — · — · —
MultiSelector 94.6 kB (+399 B) · 16.8 kB CSS (0) — — · — · —
MobileNav 70.5 kB (+398 B) · 10.6 kB CSS (0) — — · — · —
lab/CommentThread 334.2 kB (+393 B) · 2.4 kB CSS (0) — — · — · —
CheckboxInput 64.2 kB (+390 B) · 9.2 kB CSS (0) — — · — · —
Markdown 180.9 kB (+390 B) · 20.5 kB CSS (0) — — · — · —
lab/TransferList 107.7 kB (+389 B) · 1.7 kB CSS (0) — — · — · —
richtext/RichTextEditorToolbar 277.2 kB (+380 B) · 454 B CSS (0) — — · — · —
AlertDialog 105.3 kB (+374 B) · 14.6 kB CSS (0) — — · — · —
ToggleButton 86.6 kB (+365 B) · 10.1 kB CSS (0) — — · — · —
NavHeadingMenu 16.3 kB (+124 B) · 3.5 kB CSS (0) — — · — · —
ProgressBar 11.7 kB (0) · 6.3 kB CSS (0) — — · — · —
layer — — — · ✓ · —
Layer — — ✓ · ✓ · —

Package size: @astryxdesign/core 7.04 MB packed (+2.2 kB); no new dependencies.

API changes: none in this pull request

Committed API report behind this build: cli 29 rows, core 40 rows, theme-butter 1 row, theme-y2k 1 row; run pnpm api:report.

Touched components checked; add ci:run-visual or ci:run-rtl to run the full suites.


Generated by PR Enrichment workflow | 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.

Changes requested. The fix works: in Chromium and WebKit, a light-dismiss layer or a DropdownMenu opened from a right click now stays open after the button comes up, and the next press outside closes it.

  • The changeset (.changeset/layer-contextmenu-release.md) and the description say a held finger is fixed too, but every test and repro uses a mouse right-button press, so either narrow the wording to a right click or add a touch reproduction that fails on main.

Optional: rename LayerContextMenuPress.a11y.chromium.spec.ts to .a11y.browser.spec.ts so the WebKit project runs it too. You could also shorten the @output line in the gestureCounter.ts header, which repeats the new function's doc comment.

[Automated review]

Comment thread .changeset/layer-contextmenu-release.md Resolved
… too

The changeset, story and claimContextMenuPress comment name the right
click that the tests cover. The real-engine spec is a browser spec, so
the WebKit project runs it as well.

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

The fix works: in Chromium and WebKit, a light-dismiss layer or a DropdownMenu opened from a right click now stays open after the button comes up, and the next press outside closes it. The changeset now names only the right click that the tests cover.

Approval waits on one owner decision. This changes what a mouse right click does for every desktop user, so it passes as a defect fix against spec:AST-003 FR11–FR13 only with an engineering owner's ruling for the current head, and the only /approve-spec on this pull request names the previous commit. An engineering owner (the author counts) can record that ruling by commenting /approve-spec followed by the current head's full SHA.

[Automated review]

@cixzhang

cixzhang commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 229ae3c

@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 fix works: in Chromium and WebKit, a light-dismiss layer or a DropdownMenu opened from a right click now stays open after the button comes up, and the next press outside closes it. The spec change is approved for this head; two implementation points remain.

  • Miss: gestureCounter.ts:55-58 adds document listeners for pointerup, pointercancel and contextmenu (and rewires pointerdown) instead of subscribing through Core's shared input owner subscribeInput in utils/inputStream.ts, which architecture:react-component-runtime INV16 and the pnpm review:pre shared-owners check require.
  • Miss: desktop behavior change needs an owner decision: while the right button that opened a light-dismiss layer is still held, the pointer capture at gestureCounter.ts:93 stops hover and focus from following the mouse over the layer (in DropdownMenu, Duplicate no longer highlights or takes focus until the button comes up and the mouse moves again), so keep hover working during that press, for example by holding the capture only while the pointer is outside the layer, or cite an owner decision that covers it.

[Automated review]

…ners join the input stream

Over the layer the capture lets go, so a held right press still
highlights a menu's rows; outside it the capture holds, so the release
there cannot dismiss the layer. The press and context-menu listeners
subscribe through the shared input stream.
A claim lasts until its press is released, so each case releases the
press it made and no claim reaches the next case.
@cixzhang

cixzhang commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 0d4a106

@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 fix works: in Chromium and WebKit, a light-dismiss layer or a DropdownMenu opened from a right click now stays open after the button comes up, the next press outside closes it, and in the light DOM hover keeps working over the menu while the button is held. The spec change is approved for this head, and the gesture counter now listens through the shared input stream.

  • Inside an open shadow root, claimContextMenuPress (gestureCounter.ts:117-121) asks document.elementFromPoint, which answers with the shadow host, so the capture never lets go over the layer and, while the opening right button is held, DropdownMenu rows neither highlight nor take focus (Chromium and WebKit); hit-test in the layer's own root as useMenuPress.ts does, and add a shadow-root case to the unit test.

Optional: the new AST-003 verification row could name WebKit beside Chromium, since the browser spec runs in both.

[Automated review]

In an open shadow root the document's hit test answers with the shadow
host, so the capture held over the layer and its rows stopped
highlighting. The test now runs in the layer's root, as the menu press
does.
…ess itself

The case moves to gestureCounter.test.ts, where the layer sits in an
open shadow root and the root's own hit test answers with the layer.
@cixzhang

cixzhang commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec b6bd39e

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

Approved pending CI: this is a draft, so CI has not run on this head yet, and marking it ready for review starts it.

The claim now hit-tests in the layer's own tree, so inside an open shadow root a DropdownMenu opened from a right click still highlights and focuses the row under the held mouse, and it stays open after the release in Chromium and WebKit. The new AST-003 verification row and the desktop fix carry an engineering owner's /approve-spec for this head.

[Automated review]

@cixzhang cixzhang added the ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) label Nov 6, 2026
…release

# Conflicts:
#	packages/core/src/Layer/useLayer.tsx
@cixzhang

cixzhang commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 856f1b6

@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 fix works: in Chromium and WebKit, a layer or a DropdownMenu opened from a right click now stays open after the button comes up and closes on the next press outside, and the AST-003 verification row carries an engineering owner's approval for this head. Two things in claimContextMenuPress need a change first:

  • Newly live check: followPointer calls elementFromPoint on every move of the opening press (packages/core/src/Layer/gestureCounter.ts:124), a layout read on a pointer-move path that INV18 of architecture:react-component-runtime rules out, and reading the layer's box once when the claim starts, then comparing clientX/clientY with it until a scroll or resize invalidates it, removes the per-move read.
  • Miss: when the layer closes while the right button is still down (Escape, say), the claim keeps capturing the pointer to the closed popover until the release, so the page under the mouse shows no hover, and ending the claim once the layer is no longer :popover-open fixes it.

[Automated review]

…d ends when the layer closes

The claim hit-tested on every move of the opening press, a layout read
on a pointer-move path. It now reads the layer's box, and the box of
each popover open inside it, once, and again only after a scroll, a
resize or a toggle inside the layer; a move compares coordinates with
those boxes. A layer that closes while the button is still down lets
the pointer go, so the page under it hovers again.
@cixzhang

cixzhang commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 0cc9d16

@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 fix works: in Chromium, a layer or a DropdownMenu opened from a right click now stays open after the button comes up, closes on the next press outside, and lets the pointer go when it closes during the press. The AST-003 verification row carries an engineering owner's approval for this head.

  • packages/core/src/Layer/gestureCounter.ts:167-168 add raw window scroll and resize listeners; subscribe both through subscribeInput from packages/core/src/utils/inputStream.ts, as the same function already does for its pointer listeners, so a change to the shared input stream reaches them too.

Non-blocking: the comment at gestureCounter.ts:114-116 reads better as short active sentences, and the description still says the claim hit-tests in the layer's own tree.

[Automated review]

@cixzhang

cixzhang commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 6ff4c88

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

Approved pending CI: CI has not run on this head yet because the pull request is a draft.

The fix works: in Chromium and WebKit, a layer or a DropdownMenu opened from a right click now stays open after the button comes up, also when the release lands away from the zone, and closes on the next press outside. The claim's scroll and resize listeners now go through subscribeInput, which resolves the last requested change, and the new AST-003 verification row carries an engineering owner's approval for this head.

Non-blocking: the new AST-003 row's Verification cell names only Chromium, while the browser spec also runs in WebKit.

[Automated review]

@cixzhang
cixzhang marked this pull request as ready for review November 8, 2026 16:44
…a press is down

The press tracking added permanent window pointerup, pointercancel and
contextmenu listeners, so the page kept a pointerup listener at rest.
They are now subscribed when a press starts and dropped when it ends.
@cixzhang

cixzhang commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 61441ce

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

Approved pending CI: the heavy suites (build, test and docsite-test) are deferred on this push and have not run on this head yet; they run in the pre-merge run.

The fix holds at this head. In Chromium and WebKit, a light-dismiss layer or a DropdownMenu opened from a right click stays open after the button comes up, also when the release lands away from the zone, and closes on the next press outside. Moving onto a menu row while the button is still down still focuses it. The AST-003 verification row carries an engineering owner's approval for this head.

Non-blocking:

  • The new comment above startPress (packages/core/src/Layer/gestureCounter.ts:36-37) is one 28-word sentence with two points; two short sentences fit the comment style.
  • The new AST-003 row's Verification cell names only Chromium, while the browser spec also runs in WebKit.

[Automated review]

Comment on lines +36 to +37
// The page listens for a press's end and its context menu only while a press
// is down, so at rest it keeps no pointerup listener of its own.

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: this is one 28-word sentence with two points (INV29 allows 25 words in a description, one topic per sentence). Shorter:

// Subscribe to the press's end and its context menu only while a press
// is down. At rest, the page keeps no pointerup listener.

@cixzhang

cixzhang commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec d8761e6

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

Approved pending CI: the heavy suites (build, test and docsite-test) are deferred on this push and have not run on this head yet; they run before merge.

The fix holds after the merge of main: in Chromium and WebKit, a light-dismiss layer or a DropdownMenu opened from a right click stays open after the button comes up. In Chromium, the next press outside closes it, and moving onto a menu row while the button is still down still focuses it. The AST-003 verification row carries an engineering owner's approval for this head.

Non-blocking:

  • The comment above startPress (packages/core/src/Layer/gestureCounter.ts:36-37) is one 28-word sentence with two points; two short sentences fit the comment style.
  • The new AST-003 row's Verification cell names only Chromium, while the browser spec also runs in WebKit.

[Automated review]

@cixzhang
cixzhang merged commit 28401fb into main Nov 8, 2026
117 of 120 checks passed
@github-actions
github-actions Bot deleted the fix/6947-contextmenu-release branch November 9, 2026 06:03

This branch was successfully deployed

1 active deployment
Preview — d8761e63 Deployed Nov 8, 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-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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[gap] DropdownMenu: DropdownMenu (@astryxdesign/core 0.6.3): a menu opened from a right-cl

1 participant