Skip to content

fix(Layer): a press inside a layer stops at the layer root in the React tree - #9497

Merged
cixzhang merged 8 commits into
mainfrom
fix/layer-click-boundary
Nov 2, 2026
Merged

cixzhang merged 8 commits into
mainfrom
fix/layer-click-boundary

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

User impact

  • Before: a press inside an open layer (a menu, popover, tooltip, hover card, dialog, drawer, lightbox, mobile navigation, bottom sheet or toast) also ran the click and pointer handlers on the elements around where the layer is written in JSX. For example, clicking the text of an open popover written inside a clickable card also activated the card. Tooltip and HoverCard surfaces were guarded against a few Core containers; everything else leaked.
  • After: the press stops at the layer root in the React tree. Handlers inside the layer, the root's own handlers, and capture-phase handlers still run. Document and window listeners still receive the press, so outside-press closing, light dismiss and deferred clicks are unchanged.
  • SelectableCard: callers keep their released onClick behavior until the next minor, though it now runs earlier (see Changes).

Spec

Builds architecture:layer-runtime INV17 (record merged in #9398). Specs ruled on the SelectableCard compatibility path: a capture-phase path, with no exemption and no hold. These records need /approve-spec:

  • architecture:layer-runtime:
    • the INV17 gap paragraph now says INV17 is met through one seam, Layer/layerClickBoundary.ts, with BottomSheetPanel's root being the BottomSheet dialog that hosts it;
    • Dialog's inline mode layers nothing and is not a root;
    • the Tooltip and HoverCard guards stay until they're removed;
    • the compatibility sentence now describes SelectableCard's capture-phase path and CLN-0026;
    • Owning code names the seam and the layer-root mark's owner, and verified_by adds the new suite.
  • component:SelectableCard:
    • its compatibility and current-state lines say that until the next minor the caller's onClick still runs for those clicks, during capture, so before the layer's own handlers; its stopPropagation() doesn't keep the press from the layer, its preventDefault() cancels only the browser's default, and a caller-written popover isn't a layer;
    • new CLN-0026 removes that handler at the minor, the staged [breaking] change.

Changes

  • Layer/layerClickBoundary.ts (new, internal): layerClickBoundary(ownProps) returns one handler for each pointer, mouse, touch and click event.
    • Each handler runs the root's own or caller's handler, then sets event.isPropagationStopped = () => true on the synthetic event.
    • React checks that before each further listener. The native stopPropagation() is never called.
  • Roots that spread it: both useLayer renderers, and the Dialog (modal), Drawer, Lightbox, MobileNav and ToastViewport roots. For BottomSheetPanel it's the BottomSheet dialog that hosts the panel (single sheet and switcher step), so a BottomSheetSwitcher's forwarded handlers still receive presses on sheet content (component:BottomSheetSwitcher FR9). Existing onClick handlers and caller rest props are composed, not overridden.
  • Layer-root mark: a private attribute, owned by privateAttributes/layerRoot.stylex.ts (public-component-api INV23), marks each root. closestLayerRoot() reads it.
  • SelectableCard: a capture-phase handler on the card root calls the caller's onClick for a click that starts inside a layer within the card. That click doesn't toggle the card, as before. It's marked for CLN-0026.
    • The layer is found through closestLayerRoot(), so a popover the caller writes themselves isn't a layer and calls onClick once, in bubble.
    • The caller's stopPropagation() is a no-op for that call, so it can't block the control inside the layer.
    • The caller's preventDefault() is applied to the native event only once the press reaches the document. A Button inside the layer still runs its clickAction, and the browser's default stays cancelled.
  • Changeset: a [fix] patch. It notes that a click inside an open layer within a SelectableCard no longer toggles the card, and that the caller's onClick now runs earlier, during capture.
  • Story: Core/Layer Dismissal gets "Press inside layer", a MoreMenu and a Popover inside a ClickableCard, with counters.
  • Follow-up (separate PR): remove the per-site guards (Tooltip/HoverCard FR11 checks, the ChatComposer FR8 guard and the others) and keep their tests.

Writing rubric results

layer-runtime.md: the INV17 state paragraph, the Owning-code line and verified_by. SelectableCard.spec.md: the compatibility class, the current-state bullet and CLN-0026.

  • R1, narration: none.
  • R2, present tense: yes. "Until the next minor" names the staged change, not history.
  • R3, evidence naming a change: none.
  • R4, one owner per fact: INV17 stays the rule; SelectableCard owns its compatibility path; the CLN lives in the SelectableCard record.
  • R5, exact ids: yes.
  • R6, verification names its case: the INV17 row's suite is layerClickBoundary.test.tsx.

Evidence

layerClickBoundary.test.tsx, 27 tests:

  • Every kind of root: each of these is tested inside a plain wrapper with onClick, onPointerDown, onGotPointerCapture and onLostPointerCapture, and inside a ClickableCard. A press inside reaches neither. The roots are an inline and a portaled useLayer layer, Dialog, Drawer, Lightbox, MobileNav, BottomSheetPanel and ToastViewport.
  • Nesting: a nested layer stops at its own root.
  • What still runs: an ancestor's capture handler and a document click listener still run, and a root's own onClick runs before the stop.
  • Native listeners still work for presses inside a layer: ContextMenu's outside mousedown, a Typeahead's deferred document click (pending show), and the keep-open control's document pointerup.
  • SelectableCard: the caller's onClick runs once for a click in an open tooltip, without toggling, and a surface click still toggles. A caller's stop doesn't block a control in the layer. A caller's preventDefault() doesn't cancel a Button's clickAction there, and the click still ends cancelled. A caller-written popover calls onClick once.
  • BottomSheetSwitcher: its forwarded onClick/onPointerDown receive a press on step content, and a wrapper around the switcher doesn't.
  • Mutations:
    • With a no-op stop, 20 of the 23 tests fail.
    • With a native stopPropagation() stop, the three listener tests and the document-click assertion fail.

Other checks:

  • The Layer, Dialog, Drawer, Lightbox, MobileNav, BottomSheet, Toast and SelectableCard suites pass (1,264 tests).
  • In the full core run, every failure also fails on main (Resizable, postinstall) or passes when rerun alone.
  • Strict lint, tsc, check:knowledge and check:changesets are clean.
  • Real Chrome (new story Core/Layer Dismissal "Press inside layer": a MoreMenu and a Popover inside a ClickableCard; measured at 74e454d, before the BottomSheet and SelectableCard follow-ups):
    • Clicking the open popover's text activated the card before (card count 0→1) and doesn't after (stays 0).
    • A click on the card's own text still activates it.
    • Choosing a menu item counts once in both builds, because ClickableCard already ignored interactive targets.

…ct tree

architecture:layer-runtime INV17. One seam, Layer/layerClickBoundary.ts,
gives every layer content root (both useLayer renderers; the Dialog,
Drawer, Lightbox, MobileNav, BottomSheetPanel and ToastViewport roots) a
handler per pointer, mouse, touch and click event. Each runs the root's own
and its caller's handler, then marks the synthetic event stopped for the
rest of the React tree (isPropagationStopped), without calling the native
stopPropagation(): ancestors of the layer's JSX position no longer receive
the press in bubble, capture handlers still run, and document and window
listeners (outside presses, light dismiss, deferred clicks) still receive
it. Dialog's inline mode layers nothing and is not a root.

SelectableCard keeps component:SelectableCard FR2's released promise until
the next minor (CLN-0026): a capture-phase handler on the card root calls
the caller's onClick for a click that starts inside a layer within the
card, without toggling.

Records: layer-runtime states INV17 met, names the seam in Owning code and
the new suite in verified_by; SelectableCard's compatibility and
current-state lines describe the capture-phase path and add CLN-0026.

Tests (layerClickBoundary.test.tsx): every kind of root inside a plain
onClick wrapper and inside a ClickableCard; a nested layer stops at its own
root; capture still runs and a document listener still sees the click; a
root's own onClick runs first; ContextMenu's outside mousedown, a
Typeahead's deferred document click and the keep-open pointerup still work
for presses inside a layer (they fail if the stop is native); the
SelectableCard compatibility path.
@vercel

vercel Bot commented Nov 2, 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 2, 2026 9:05am UTC

Request Review

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

astracat-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 2, 2026, 9:23 AM UTC

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 2, 2026
… a clickable card

Shows INV17 in a real browser: choosing a menu item or clicking popover
text counts in the layer and does not activate the card around it.
@cixzhang

cixzhang commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 74e454d

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

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 9a858e2

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
MoreMenu 71.1 kB (+304 B) · 15.4 kB CSS (0) — — · — · —
DropdownMenu 70.8 kB (+303 B) · 15.4 kB CSS (0) — — · — · —
ContextMenu 73.0 kB (+291 B) · 15.3 kB CSS (0) — — · — · —
115 more components
Component Size LoC Visual · A11y · RTL
TableCell 74.2 kB (+287 B) · 15.8 kB CSS (0) — — · — · —
TableHeaderCell 73.8 kB (+283 B) · 15.5 kB CSS (0) — — · — · —
richtext/RichTextEditorToolbar 219.5 kB (+280 B) · 454 B CSS (0) — — · — · —
PowerSearch 180.0 kB (+268 B) · 20.5 kB CSS (0) — — · — · —
DateTimeInput 111.0 kB (+264 B) · 15.8 kB CSS (0) — — · — · —
lab/TransferListSelector 78.6 kB (+258 B) · 1.9 kB CSS (0) — — · — · —
lab/Comments 229.8 kB (+257 B) · 2.5 kB CSS (0) — — · — · —
Table 82.9 kB (+254 B) · 16.0 kB CSS (0) — — · — · —
lab/CommentComposer 100.1 kB (+253 B) · 1.9 kB CSS (0) — — · — · —
lab/MobilePowerSearch 164.4 kB (+253 B) · 1.2 kB CSS (0) — — · — · —
RadioList 41.1 kB (+251 B) · 8.3 kB CSS (0) — — · — · —
lab/TransferList 72.3 kB (+249 B) · 1.7 kB CSS (0) — — · — · —
DateInput 98.7 kB (+247 B) · 15.3 kB CSS (0) — — · — · —
SideNav 63.4 kB (+245 B) · 10.9 kB CSS (0) — — · — · —
Markdown 143.6 kB (+241 B) · 18.3 kB CSS (0) — — · — · —
charts/ChartTooltip 50.3 kB (+237 B) · 20 B CSS (0) — — · — · —
CheckboxList 41.5 kB (+235 B) · 8.6 kB CSS (0) — — · — · —
lab/CommentThread 224.5 kB (+235 B) · 2.4 kB CSS (0) — — · — · —
charts/Chart 60.9 kB (+234 B) · 20 B CSS (0) — — · — · —
BottomSheet 35.0 kB (+232 B) · 7.5 kB CSS (0) — — · — · —
charts/ChartLegend 50.4 kB (+230 B) · 20 B CSS (0) — — · — · —
Dialog 16.6 kB (+230 B) · 6.6 kB CSS (0) — — · — · —
Pagination 84.1 kB (+229 B) · 15.9 kB CSS (0) — — · — · —
Drawer 34.3 kB (+228 B) · 8.2 kB CSS (0) — — · — · —
LayerProvider 60.8 kB (+228 B) · 10.5 kB CSS (0) — — · — · —
TopNav 49.5 kB (+228 B) · 10.7 kB CSS (0) — — · — · —
SelectableCard · Storybook 14.5 kB (+227 B) · 7.3 kB CSS (0) 355 (+50) — · — · —
AlertDialog 53.8 kB (+225 B) · 12.7 kB CSS (0) — — · — · —
lab/ChatEmojiPicker 62.8 kB (+225 B) · 773 B CSS (0) — — · — · —
lab/ChatReactionBar 63.3 kB (+225 B) · 1.1 kB CSS (0) — — · — · —
lab/Schedule 57.8 kB (+224 B) · 3.9 kB CSS (0) — — · — · —
lab/TourStep 51.8 kB (+223 B) · 590 B CSS (0) — — · — · —
CommandPalette 48.2 kB (+222 B) · 12.2 kB CSS (0) — — · — · —
DateRangeInput 67.6 kB (+222 B) · 11.7 kB CSS (0) — — · — · —
Selector 75.0 kB (+222 B) · 15.6 kB CSS (0) — — · — · —
MobileNav 48.0 kB (+221 B) · 10.4 kB CSS (0) — — · — · —
MultiSelector 70.9 kB (+221 B) · 15.2 kB CSS (0) — — · — · —
AvatarGroupOverflow 36.3 kB (+220 B) · 6.5 kB CSS (0) — — · — · —
Tokenizer 67.8 kB (+220 B) · 17.1 kB CSS (0) — — · — · —
Popover 46.5 kB (+218 B) · 12.4 kB CSS (0) — — · — · —
BaseTypeahead 52.8 kB (+217 B) · 10.2 kB CSS (0) — — · — · —
lab/InfoTip 23.4 kB (+216 B) · 458 B CSS (0) — — · — · —
StatusDot 20.4 kB (+215 B) · 6.3 kB CSS (0) — — · — · —
lab/MobileTokenizer 99.0 kB (+215 B) · 880 B CSS (0) — — · — · —
RadioListItem 49.5 kB (+212 B) · 10.1 kB CSS (0) — — · — · —
TableSelectionToolbar 49.4 kB (+212 B) · 11.5 kB CSS (0) — — · — · —
ChatComposerTokenElement 53.5 kB (+210 B) · 10.4 kB CSS (0) — — · — · —
ListItem 51.0 kB (+210 B) · 11.0 kB CSS (0) — — · — · —
ChatComposerInput 53.5 kB (+209 B) · 10.4 kB CSS (0) — — · — · —
TabList 35.4 kB (+209 B) · 7.5 kB CSS (0) — — · — · —
Toolbar 34.7 kB (+208 B) · 7.9 kB CSS (0) — — · — · —
TopNavMegaMenu 51.4 kB (+208 B) · 11.2 kB CSS (0) — — · — · —
lab/ListInput 80.0 kB (+208 B) · 1.6 kB CSS (0) — — · — · —
BreadcrumbItem 64.9 kB (+205 B) · 11.4 kB CSS (0) — — · — · —
lab/CommentPin 44.5 kB (+205 B) · 1.2 kB CSS (0) — — · — · —
CheckboxListItem 51.6 kB (+203 B) · 11.0 kB CSS (0) — — · — · —
Field 39.6 kB (+203 B) · 8.3 kB CSS (0) — — · — · —
Lightbox · Storybook 48.3 kB (+203 B) · 10.1 kB CSS (0) 819 (+4) — · — · —
Link 40.2 kB (+203 B) · 7.9 kB CSS (0) — — · — · —
Carousel 47.3 kB (+202 B) · 10.5 kB CSS (0) — — · — · —
InputGroup 40.2 kB (+202 B) · 8.4 kB CSS (0) — — · — · —
TextArea 45.2 kB (+202 B) · 9.8 kB CSS (0) — — · — · —
TimeInput 86.5 kB (+201 B) · 14.3 kB CSS (0) — — · — · —
AppShell 65.8 kB (+200 B) · 12.1 kB CSS (0) — — · — · —
SegmentedControl 34.2 kB (+199 B) · 6.5 kB CSS (0) — — · — · —
FieldLabel 33.3 kB (+198 B) · 5.9 kB CSS (0) — — · — · —
AvatarGroup 35.2 kB (+197 B) · 6.6 kB CSS (0) — — · — · —
Switch 45.2 kB (+197 B) · 9.7 kB CSS (0) — — · — · —
Thumbnail 47.5 kB (+197 B) · 11.3 kB CSS (0) — — · — · —
Toast · Storybook 56.7 kB (+197 B) · 10.1 kB CSS (0) 1,515 (+2) — · — · —
TopNavMenu 55.2 kB (+197 B) · 10.5 kB CSS (0) — — · — · —
CheckboxInput 46.9 kB (+196 B) · 9.7 kB CSS (0) — — · — · —
lab/EmojiPicker 68.1 kB (+196 B) · 722 B CSS (0) — — · — · —
ChatSendButton 42.4 kB (+195 B) · 9.5 kB CSS (0) — — · — · —
NumberInput 53.1 kB (+195 B) · 11.2 kB CSS (0) — — · — · —
TextInput 50.8 kB (+195 B) · 10.9 kB CSS (0) — — · — · —
Typeahead 60.6 kB (+195 B) · 11.8 kB CSS (0) — — · — · —
richtext/RichTextEditor 274.3 kB (+195 B) · 2.6 kB CSS (0) — — · — · —
Calendar 52.2 kB (+194 B) · 10.3 kB CSS (0) — — · — · —
ComplexSelector 53.5 kB (+193 B) · 11.1 kB CSS (0) — — · — · —
Tooltip 18.2 kB (+193 B) · 5.0 kB CSS (0) — — · — · —
Slider 44.4 kB (+192 B) · 8.9 kB CSS (0) — — · — · —
ToggleButton 40.5 kB (+192 B) · 9.6 kB CSS (0) — — · — · —
Avatar 32.4 kB (+191 B) · 6.5 kB CSS (0) — — · — · —
ChatLayout 45.7 kB (+191 B) · 10.3 kB CSS (0) — — · — · —
ChatLayoutScrollButton 43.1 kB (+191 B) · 9.9 kB CSS (0) — — · — · —
DialogHeader 45.6 kB (+191 B) · 10.2 kB CSS (0) — — · — · —
DropdownMenuSubMenu 55.9 kB (+191 B) · 9.9 kB CSS (0) — — · — · —
IconButton 39.6 kB (+191 B) · 9.5 kB CSS (0) — — · — · —
TabMenu 52.4 kB (+191 B) · 10.4 kB CSS (0) — — · — · —
ChatComposer 58.9 kB (+189 B) · 11.2 kB CSS (0) — — · — · —
richtext/RichTextView 254.8 kB (+189 B) · 2.3 kB CSS (0) — — · — · —
ChatDictationButton 43.2 kB (+188 B) · 9.8 kB CSS (0) — — · — · —
CodeBlock 57.0 kB (+187 B) · 11.1 kB CSS (0) — — · — · —
MobileNavToggle 43.0 kB (+187 B) · 9.7 kB CSS (0) — — · — · —
SideNavCollapseButton 43.4 kB (+187 B) · 9.8 kB CSS (0) — — · — · —
Banner 44.6 kB (+185 B) · 10.3 kB CSS (0) — — · — · —
Button 39.6 kB (+185 B) · 9.5 kB CSS (0) — — · — · —
SideNavHeading 55.9 kB (+185 B) · 10.5 kB CSS (0) — — · — · —
SideNavItem 51.8 kB (+185 B) · 10.4 kB CSS (0) — — · — · —
Stepper 44.2 kB (+185 B) · 9.9 kB CSS (0) — — · — · —
FileInput 51.8 kB (+184 B) · 10.7 kB CSS (0) — — · — · —
TopNavHeading 55.3 kB (+183 B) · 10.4 kB CSS (0) — — · — · —
DrawerHeader 45.7 kB (+181 B) · 11.6 kB CSS (0) — — · — · —
HoverCard 18.5 kB (+180 B) · 5.0 kB CSS (0) — — · — · —
ChatToolCalls 25.8 kB (+1 B) · 9.3 kB CSS (0) — — · — · —
Timestamp 21.3 kB (+1 B) · 9.9 kB CSS (0) — — · — · —
BottomSheetSwitcher 15.0 kB (0) · 3.4 kB CSS (0) — — · — · —
ChatMessageList 22.7 kB (0) · 7.9 kB CSS (0) — — · — · —
CommandPaletteInput 26.6 kB (0) · 8.5 kB CSS (0) — — · — · —
Heading 7.9 kB (0) · 6.0 kB CSS (0) — — · — · —
Spinner 18.5 kB (0) · 6.7 kB CSS (0) — — · — · —
Text 7.4 kB (0) · 6.0 kB CSS (0) — — · — · —
Timer 9.5 kB (0) · 7.0 kB CSS (0) — — · — · —
ProgressBar 7.9 kB (−1 B) · 6.9 kB CSS (0) — — · — · —

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

API changes: none in this pull request

Committed API report behind this build: core 5 rows; run pnpm api:report.

Wide change (8 components): add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.


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 layer click boundary matches INV17 and the spec approval covers the SelectableCard path, but two regressions need fixing first.

  • A SelectableCard whose onClick calls stopPropagation() now cancels clicks on menus and popovers inside the card, because the compatibility call runs during capture; please keep that stop from reaching the layer and add a test.
  • BottomSheetSwitcher's forwarded onClick and onPointerDown no longer fire for presses on sheet content, as its FR9 promises they will; please hand them to the panel's boundary and add a test.
  • The menu example in the description and the PressInsideLayer story comment does not reproduce with ClickableCard, which already ignored menu items, so please reword it to the popover-text case.

[Automated review]

}
const layer = target.closest('[popover], dialog');
if (layer != null && !layer.contains(e.currentTarget)) {
onClickProp(e);

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.

This runs during capture, before the layer's own handlers, so a caller onClick that calls event.stopPropagation() now stops the press before it reaches a menu item or popover control inside the card. In Chromium, a MoreMenu item in such a card stops working. Consider calling the caller's handler with stopPropagation() neutralised for this call, and asking the seam for layer roots rather than closest('[popover], dialog'), which also double-calls onClick for a caller-authored popover.

)}
// A press inside the sheet stops at its root (layer-runtime INV17),
// after the caller's handlers run.
{...layerClickBoundary(props)}>

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.

In a BottomSheetSwitcher, the switcher's forwarded handlers sit on the step's <dialog>, the parent of this panel (BottomSheet.tsx around line 1182). Stopping here means a switcher onClick or onPointerDown no longer fires for presses on sheet content, which FR9 promises. Those handlers need composing into this boundary for switcher steps.

…dlers still receive presses

The boundary sat on BottomSheetPanel, inside the dialog that a
BottomSheetSwitcher forwards its handlers to (component:BottomSheetSwitcher
FR9), so a switcher onClick or onPointerDown stopped firing for presses on
sheet content. The boundary now sits on both BottomSheet dialogs (the
single sheet's and a switcher step's), composing the switcher's forwarded
handlers and the dialog's own; layer-runtime names that dialog as the
panel's root. Test: the switcher's handlers receive a press on step content
and a wrapper around the switcher does not (fails with the panel placement).
…seam and ignores a caller's stop

- The boundary marks every layer root through a private attribute owned by
  privateAttributes/layerRoot.stylex.ts; SelectableCard's capture-phase
  path asks closestLayerRoot instead of closest('[popover], dialog'), so a
  popover the caller writes themselves is not a layer and its click reaches
  onClick once, in bubble.
- In capture, a caller's stopPropagation() would keep the press from the
  control inside the layer; it is a no-op for that call.
- SelectableCard's current-state line and layer-runtime's Owning code say
  so. Tests: a caller stop does not block a control in the layer; a
  caller-written popover calls onClick once (both fail with the previous
  path).
@cixzhang

cixzhang commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec ec06267

@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 layer click boundary matches INV17, the spec approval covers the BottomSheet root and the SelectableCard capture path, and the earlier SelectableCard and BottomSheetSwitcher regressions are fixed and tested. Two small fixes remain:

  • Add onGotPointerCapture and onLostPointerCapture to BOUNDARY_EVENTS: INV17 covers every pointer event, and a wrapper around a popover still receives those two from inside it, so please assert them in the wrapper test too.
  • The changeset says a click inside a layer in a SelectableCard "still does not toggle the card", but on the base a click on popover text did toggle it; please describe this as a change, and fix "as before" in the description.

[Automated review]

Comment on lines +27 to +47
const BOUNDARY_EVENTS = [
'onClick',
'onAuxClick',
'onDoubleClick',
'onContextMenu',
'onMouseDown',
'onMouseUp',
'onMouseMove',
'onMouseOver',
'onMouseOut',
'onPointerDown',
'onPointerUp',
'onPointerMove',
'onPointerOver',
'onPointerOut',
'onPointerCancel',
'onTouchStart',
'onTouchMove',
'onTouchEnd',
'onTouchCancel',
] as const;

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.

onGotPointerCapture and onLostPointerCapture are missing here. Both bubble through the React tree, so a wrapper around a popover still runs its handler when a slider or drag handle inside the layer takes or releases pointer capture, which INV17 ("a pointer, mouse, touch, or click event") rules out. Adding both props, and asserting them in the wrapper test, closes it.

…capture; changeset names SelectableCard's toggle change

Both bubble through the React tree, so a wrapper around a layer still ran
its handler when a control inside took or released pointer capture. The
wrapper test now asserts both (fails without them). The changeset says a
click inside an open layer within a SelectableCard no longer toggles it,
which the base did for popover content.
@cixzhang

cixzhang commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 7141816

@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 layer click boundary matches INV17 at every root, and the pointer-capture and changeset fixes are in. One fix remains:

  • SelectableCard calls the caller's onClick during capture without shielding preventDefault(), so a caller that calls it now cancels a Button's clickAction inside a popover in the card, which ran before; please forward that call to the native event only, as stopPropagation() is already shielded, and add a test.
  • The description still says such a click doesn't toggle the card "as before", but on the base a click on popover text did toggle it; please reword it.

[Automated review]

Comment on lines +437 to +442
const stopPropagation = e.stopPropagation;
e.stopPropagation = () => {};
try {
onClickProp(e);
} finally {
e.stopPropagation = stopPropagation;

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.

This shields stopPropagation(), but a caller onClick that calls preventDefault() still runs before the layer's handlers and marks the event cancelled for them: a Button inside the popover then skips its clickAction (Button.tsx checks !e.defaultPrevented), which ran before this change. Forwarding the caller's preventDefault() to e.nativeEvent.preventDefault() for this call keeps the native default cancelled without the layer's handlers seeing it; a test with a clickAction Button inside the popover would pin it.

…ath no longer cancels controls inside the layer; comments give reasons only

- The capture-phase call ran the caller's onClick before the layer's own
  handlers, so its preventDefault() marked the press handled and a Button
  inside the popover skipped its clickAction. callBeforeLayerHandlers now
  records the caller's preventDefault() and applies it to the native event
  once the press reaches the document, where it still cancels the browser's
  default; stopPropagation() stays a no-op. SelectableCard's current-state
  line says so. Test: a clickAction Button in a popover runs, and the click
  is still cancelled (fails before).
- New comments give reasons only, without record citations
  (architecture:knowledge-contracts INV29, now on main); the records link
  these files.
@cixzhang

cixzhang commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 9a858e2

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

This looks ready to merge: the layer click boundary meets the layer runtime's INV17 at every root, the spec changes are approved at this head, and the earlier SelectableCard preventDefault() issue is fixed and tested. A few optional follow-ups:

  • SelectableCard runs its compatibility onClick before a caller's own onClickCapture, so a caller that stops propagation there no longer keeps onClick from running for clicks inside a layer; calling the caller's capture handler first and skipping when propagation is stopped keeps the released order.
  • A few new comments could be trimmed: the layerClickBoundary.ts header repeats the function JSDoc, one sentence in callBeforeLayerHandlers runs to 41 words, and the repeated "Presses inside the … do not reach handlers" lines restate the helper.

[Automated review]

Comment on lines +516 to +523
onClickCapture={
!isDisabled && handleLayerClickCapture
? (e: MouseEvent<HTMLDivElement>) => {
handleLayerClickCapture(e);
props.onClickCapture?.(e);
}
: props.onClickCapture
}>

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: the compatibility call runs before the caller's own onClickCapture. A caller whose onClickCapture calls stopPropagation() used to keep onClick from running for a click inside a layer in the card; now onClick runs anyway. Calling props.onClickCapture?.(e) first and skipping handleLayerClickCapture when e.isPropagationStopped() keeps the released order.

Comment on lines +14 to +20
* A press that starts inside a layer runs the handlers inside the layer and
* the root's own, then stops propagating through the React tree, so no
* bubble-phase handler on an ancestor of the layer's JSX position receives it.
* Capture-phase handlers on those ancestors already ran. The stop is
* React-only: it marks the synthetic event stopped and never calls the
* native `stopPropagation()`, so document and window listeners (outside
* presses, light dismiss, deferred clicks) still receive the press.

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 paragraph repeats the JSDoc on layerClickBoundary and stopInReactTree and takes the header to 17 lines. Keeping @file, @input, @output and @position is enough.

Comment on lines +331 to +334
* so it does nothing here. Its preventDefault() would mark the event handled
* for those controls (a Button skips its clickAction), so it is applied to
* the native event only after the press has bubbled to the document, where it
* still cancels the browser's default action.

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 41-word passive sentence. A shorter form: "Its preventDefault() would make those controls skip their work, as a Button skips its clickAction. So the call waits until the press reaches the document. There it cancels only the browser's default action."

@cixzhang
cixzhang merged commit 09a482e into main Nov 2, 2026
136 of 140 checks passed
@github-actions
github-actions Bot deleted the fix/layer-click-boundary branch November 3, 2026 06:05

This branch was successfully deployed

1 active deployment
Preview — 9a858e2b Deployed Nov 2, 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. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant