Skip to content

fix(Popover): a children-mode trigger attaches only when what it reads changes - #13155

Merged
cixzhang merged 21 commits into
mainfrom
fix/popover-children-attach-once
Nov 23, 2026
Merged

cixzhang merged 21 commits into
mainfrom
fix/popover-children-attach-once

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

User impact

A product team reported React's "Maximum update depth exceeded" from the documented children-mode Popover (<Popover content={…}><IconButton …/></Popover>), with a stack through Popover's trigger attach. The loop came from the page itself: its trigger's text changed on every render. In a real Chromium reproduction of the reported pattern (a toolbar whose trigger label switches between wide and short from a width check in a layout effect, during a window resize sweep), the same error fires on main with the reported stack, and the same page without a Popover throws it too, at the same width, because the wide label takes the space it measures. Popover was only where the loop surfaced: on every render it detached and re-attached its trigger's listeners and ARIA attributes and read the trigger's text, so its update was the first past React's nested-update limit. After this change a Popover whose props and trigger stay the same no longer detaches and re-attaches its trigger on re-render; a trigger the caller swaps, remounts or turns into a render function stays attached and the popover anchors to it, and a sheet with no label still follows its trigger's text. A page whose trigger text changes on every render still re-renders each time, with or without this change; that is the page's defect.

Problem and solution fit

  • Why it happens: Popover's two trigger-attach layout effects, and the click handler they attach, list the whole popover object from usePopoverInternal as a dependency. That object (and its triggerProps) is new on every render, so the effects ran after every render: detach, attach, and setTriggerText(readTriggerText(button)).
  • Why it harms the task: a state update from an effect that runs after every render re-renders Popover; if the trigger's text differs on that render, the effect sets it again, until React stops the page.
  • Why that matters: product teams hit it with plain, documented usage and have no workaround in app code.

The fix attaches the trigger through Core's useAttachment, the attach-and-release lifecycle the gesture hooks, the pager and useAnimator share. useAttachment now also accepts a function that finds its node after each commit, because the trigger is a button inside the caller's children or behind the caller's anchorRef. Popover attaches the anchor (keyed on the popover's trigger ref) and the trigger button (keyed on attachTrigger) through it, so it attaches again only when the element or its key changed; a small layout check beside them follows a change to the trigger's text. The click handler depends on the popover's stable members instead of the whole object, and onOpenChange is read through a committed ref, so an inline callback no longer gives the popover new show, hide and toggle callbacks on every render. The public usePopover return is not memoized, so no new identity contract appears.

Expected behavior and authority

  • architecture:react-component-runtime INV3: ordinary re-render synchronization must not repeat one-time work, and synchronization stays idempotent under its dependencies.

Smallest restoration

Popover.tsx, plus a function form for hooks/useAttachment.ts (internal, not exported from the package): Popover's anchor and trigger button attach through useAttachment; the release clears the anchor only while it is still the one it set, so a render-prop trigger that takes over keeps its anchor; a layout check sets the trigger text only when it changed; handleTriggerClick and the render-prop trigger ref read stable popover members; onOpenChange through useCommittedRef. No API, visual or interaction change: a replaced trigger is attached as before.

No new attach lifecycle is added: main's two attach layout effects are replaced by two useAttachment calls on the shared lifecycle, and one small layout check follows the trigger's text. An effect is still the tool, not a callback ref: the trigger is an element inside the caller's children (or behind the caller's anchorRef), so no ref callback of Popover's fires when it is swapped, and its text can only be read from the DOM after commit.

Evidence

  • Reproduction before the change: Popover.attachOnce.test.tsx "attaches its trigger once across re-renders that change nothing it reads" fails on main's code (the trigger's click listener is added 7 times against 2 at mount over five parent re-renders), and so does the same check with an inline onOpenChange.
  • Result after the change: both pass.
  • Representative unchanged path: when children change from an element to a render function, the popover opens anchored to the render-prop trigger (PopoverTriggerSwitch.interaction.browser.spec.ts in Chromium, with its story: on the earlier head whose release cleared that anchor the popover opens unanchored and the spec fails; here and on main it passes); a sheet with no label renames itself when its trigger's text changes while it is open (PopoverPresentation.test.tsx, DEC-8); a trigger the caller swaps for another element, a trigger remounted under a new key, and a button behind anchorRef that remounts each get aria-haspopup and the click listener; the existing Popover suites pass.
  • Regression test or other mutation-sensitive proof: the attach-once tests fail if the attach runs after every render again, and the replaced-trigger tests fail if the attach stops following the trigger element.

Scope

Components: Popover

  • 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

  • Popover.attachOnce.test.tsx (7 tests), useAttachment.test.tsx (the function form) and the DEC-8 case in PopoverPresentation.test.tsx pass at this head. Over main's Popover.tsx, the two attach-once tests fail (7 attaches against 2) and the replaced-trigger and DEC-8 cases pass; over the earlier head 45a0598f's Popover.tsx, the inline-onOpenChange and three replaced-trigger tests fail; the DEC-8 case fails on the commit before its fix.
  • useAttachment consumers: every Core module that imports hooks/useAttachment.ts (13, found by a static import map of packages/core/src) passes its own tests and its callers' tests at this head (vitest --project ui, 228 files, 7,009 tests, none failed):
Consumer Own tests Callers' tests
Popover/Popover.tsx 565 (11 files) 1,674 (42 files)
Toolbar/Toolbar.tsx 111 (3) 287 (14)
Lightbox/Lightbox.tsx 311 (10) 252 (10)
Lightbox/useZoomCore.ts none (covered through Lightbox) 311 (10)
Carousel/Carousel.tsx 72 (3) 242 (10)
gestures/useFingerScroll.ts 28 (2) none (its caller has no test file)
gestures/useGestureRecognizer.ts 257 (4) 547 (15)
gestures/usePressTracker.ts 245 (3) 378 (12)
hooks/usePager.ts (pair) 161 (1) 415 (12)
hooks/useDragToSnapPoints.ts 75 (5) 471 (15)
hooks/usePanGesture.ts 81 (5) 471 (15)
hooks/useAnimator.ts 72 (5) 471 (15)
keyboard/useMobileKeyboard.ts 197 (3) 1,126 (26)

The existing callers pass a ref, which takes the same path as before; useAttachmentPair.test.tsx (5) and the gesture suites cover it, and the new useAttachment.test.tsx covers the function form.

  • PopoverTriggerSwitch.interaction.browser.spec.ts in Chromium on built Storybook: 5 of 5 pass at this change; on the earlier head whose release cleared the render-prop trigger's anchor, all 3 runs fail (the layer opens unanchored, 538 px from its trigger).
  • pnpm preflight --browser at 0565065, the head before the latest main merge (strict lint, the full Chromium interaction suite): every step passes except one Switch interaction case outside this change (below), including pnpm review:pre with no findings, the attach-once tests (the replaced-trigger cases now also click the new trigger and open the popover), the 34 PopoverPresentation tests (main's tab-behaviour change added 2), PopoverTriggerSwitch, every useAttachment consumer's tests, and the new Popover suites from main. That Switch case failed its strict 4 px check under heavy load, at exactly the limit; its graph does not include the files this pull request changes, and it does not reproduce (1 of 40 at this change, 0 of 40 on main). The interaction-timing floor passes here: it counts the 142 specs the timing record lists, all timed; ten newer specs, this one and nine from main, have no time yet.
  • pnpm size:pages at this head against its main parent (first-load JavaScript, minified / gzip bytes): docs +0 / +0, form +25 / +9, menu +0 / −1, table +0 / −1. Only the form page keeps useAttachment in its first-load chunks (through TextInput's mobile keyboard), and the function form is its whole +25 B; menu and table differ by one byte of compression at an equal minified size.
  • An earlier head's preflight hit one interaction test outside this change, DropdownMenu/__tests__/MenuSheetRowsAtOpen.interaction.browser.spec.ts, which timed out waiting for its dialog on a heavily loaded machine. It passes 25 of 25 runs at that head and 25 of 25 on main's code. Its menu sheet renders BottomSheet, whose useMobileKeyboard attaches through useAttachment with a ref, the branch this change leaves as it was; it does not render Popover.tsx (DropdownMenu uses usePopover.tsx).

Reach of the shared change

useAttachment and useAttachmentPair now also accept a function that returns the node. The change is additive: a caller that passes a ref reads ref.current after each commit, as before. Popover is the only caller that passes a function: its children-mode and anchorRef triggers attach through it, so <Popover anchorRef> callers run the changed code too; a render-prop trigger keeps its ref callback. DropdownMenu builds on usePopoverInternal and does not use Popover's trigger wiring, so its trigger path does not run the changed code.

Five re-renders of the parent that change nothing Popover reads must not
attach the trigger again. On main the attach runs after every render.
…s changes

The trigger attach effects and the click handler depended on the whole
popover object, which is new on every render. So the trigger detached and
attached again after each render and set its text each time, and a text that
changed between renders looped until React stopped it. They now depend on
the members they read, and the text update keeps an unchanged text.
@vercel

vercel Bot commented Nov 21, 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 22, 2026 10:22pm UTC

Request Review

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

astracat-bot Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

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

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 45a0598

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 1374221

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
Popover · Storybook 106.0 kB (+311 B) · 15.5 kB CSS (0) 1,857 (+32) ✓ · ✓ · ✓
lab/ChatEmojiPicker 129.4 kB (+201 B) · 773 B CSS (0) — — · — · —
lab/CommentComposer 187.2 kB (+194 B) · 1.9 kB CSS (0) — — · — · —
65 more components
Component Size LoC Visual · A11y · RTL
lab/ChatReactionBar 130.6 kB (+177 B) · 1.1 kB CSS (0) — — · — · —
richtext/RichTextEditorToolbar 317.1 kB (+175 B) · 454 B CSS (0) — — · — · —
lab/CommentThread 383.8 kB (+160 B) · 2.4 kB CSS (0) — — · — · —
lab/Comments 390.8 kB (+153 B) · 2.5 kB CSS (0) — — · — · —
lab/MediaCaptionsButton 229.4 kB (+56 B) · 1.5 kB CSS (0) — — · — · —
lab/MediaPlaybackRate 229.4 kB (+56 B) · 1.5 kB CSS (0) — — · — · —
lab/MediaPlayButton 229.4 kB (+56 B) · 1.5 kB CSS (0) — — · — · —
lab/MediaSeekButton 229.4 kB (+56 B) · 1.5 kB CSS (0) — — · — · —
lab/MediaTime 229.4 kB (+56 B) · 1.5 kB CSS (0) — — · — · —
lab/MediaTimeSlider 229.4 kB (+56 B) · 1.5 kB CSS (0) — — · — · —
lab/MediaFullscreenButton 229.4 kB (+55 B) · 1.5 kB CSS (0) — — · — · —
lab/MediaVolume 229.4 kB (+55 B) · 1.5 kB CSS (0) — — · — · —
lab/AudioPlayer 239.2 kB (+32 B) · 1.8 kB CSS (0) — — · — · —
lab/Schedule 119.2 kB (+18 B) · 3.9 kB CSS (0) — — · — · —
PowerSearch 320.5 kB (+15 B) · 27.3 kB CSS (0) — — · — · —
TableSelectionToolbar 78.4 kB (+12 B) · 14.6 kB CSS (0) — — · — · —
Toast 107.7 kB (+12 B) · 11.5 kB CSS (0) — — · — · —
lab/ChatVirtualizer 57.8 kB (+12 B) · 223 B CSS (0) — — · — · —
Lightbox 151.6 kB (+11 B) · 12.3 kB CSS (0) — — · — · —
TextInput 101.7 kB (+11 B) · 12.9 kB CSS (0) — — · — · —
ToggleButton 95.2 kB (+11 B) · 11.3 kB CSS (0) — — · — · —
lab/TransferListSelector 151.9 kB (+11 B) · 1.4 kB CSS (0) — — · — · —
ButtonGroup 45.0 kB (+10 B) · 3.7 kB CSS (0) — — · — · —
ToggleButtonGroup 42.2 kB (+10 B) · 3.7 kB CSS (0) — — · — · —
lab/NavigationScreen 86.6 kB (+10 B) · 1.5 kB CSS (0) — — · — · —
lab/NavigationStack 86.6 kB (+10 B) · 1.5 kB CSS (0) — — · — · —
lab/PageControl 79.2 kB (+10 B) · 709 B CSS (0) — — · — · —
AlertDialog 134.5 kB (+9 B) · 16.3 kB CSS (0) — — · — · —
DateInput 209.8 kB (+9 B) · 19.0 kB CSS (0) — — · — · —
Pagination 154.8 kB (+9 B) · 20.1 kB CSS (0) — — · — · —
SegmentedControl 103.7 kB (+9 B) · 7.2 kB CSS (0) — — · — · —
lab/TransferList 140.0 kB (+9 B) · 1.2 kB CSS (0) — — · — · —
TextArea 95.4 kB (+8 B) · 10.0 kB CSS (0) — — · — · —
lab/EmojiPicker 121.3 kB (+8 B) · 751 B CSS (0) — — · — · —
lab/VideoPlayer 236.7 kB (+8 B) · 2.1 kB CSS (0) — — · — · —
DateTimeInput 234.0 kB (+7 B) · 20.7 kB CSS (0) — — · — · —
TimeInput 182.3 kB (+7 B) · 17.9 kB CSS (0) — — · — · —
lab/TabBar 84.7 kB (+7 B) · 1.8 kB CSS (0) — — · — · —
NumberInput 106.7 kB (+6 B) · 13.1 kB CSS (0) — — · — · —
Toolbar 48.4 kB (+6 B) · 8.6 kB CSS (0) — — · — · —
BottomSheet 76.9 kB (+5 B) · 7.8 kB CSS (0) — — · — · —
Carousel 78.2 kB (+4 B) · 12.1 kB CSS (0) — — · — · —
ContextMenuItem 39.1 kB (+1 B) · 7.3 kB CSS (0) — — · — · —
Item 20.9 kB (+1 B) · 6.2 kB CSS (0) — — · — · —
TableCell 107.9 kB (+1 B) · 20.2 kB CSS (0) — — · — · —
TableHeaderCell 107.8 kB (+1 B) · 20.0 kB CSS (0) — — · — · —
CheckboxListItem 82.7 kB (0) · 12.6 kB CSS (0) — — · — · —
ContextMenu 106.7 kB (0) · 19.6 kB CSS (0) — — · — · —
DropdownMenu 133.2 kB (0) · 19.8 kB CSS (0) — — · — · —
DropdownMenuCheckboxItem 29.6 kB (0) · 7.6 kB CSS (0) — — · — · —
DropdownMenuRadioItem 29.6 kB (0) · 7.6 kB CSS (0) — — · — · —
DropdownMenuSubMenu 80.9 kB (0) · 11.0 kB CSS (0) — — · — · —
RadioListItem 78.8 kB (0) · 11.2 kB CSS (0) — — · — · —
Selector 121.5 kB (0) · 19.7 kB CSS (0) — — · — · —
SelectorOption 24.8 kB (0) · 6.8 kB CSS (0) — — · — · —
Tokenizer 113.1 kB (0) · 21.9 kB CSS (0) — — · — · —
lab/TabBarItem 3.9 kB (0) · 1.8 kB CSS (0) — — · — · —
lab/TabBarMoreList 105.2 kB (0) · 1.8 kB CSS (0) — — · — · —
BreadcrumbItem 103.0 kB (−1 B) · 14.0 kB CSS (0) — — · — · —
DropdownMenuItem 28.7 kB (−1 B) · 7.1 kB CSS (0) — — · — · —
ListItem 81.9 kB (−1 B) · 12.6 kB CSS (0) — — · — · —
Markdown 210.8 kB (−1 B) · 23.5 kB CSS (0) — — · — · —
MoreMenu 133.5 kB (−1 B) · 19.8 kB CSS (0) — — · — · —
MultiSelector 109.8 kB (−1 B) · 18.9 kB CSS (0) — — · — · —
Table 126.1 kB (−2 B) · 21.2 kB CSS (0) — — · — · —

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

Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-rtl for RTL.


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. Narrowing the trigger wiring's dependencies stops the per-render re-attach for a Popover with stable props, but it also stops a replaced trigger from being attached, and the release note promises more than the change does.

  • A trigger element that React replaces (a conditional IconButton/Button swap, a keyed remount, or an anchorRef that moves to a remounted button) never gets its click listener or aria-haspopup/aria-expanded/aria-controls (Popover.tsx:1014, :1056), so a click on it opens nothing; keep the attach idempotent per node and add a swapped-trigger test.
  • The release note's "no longer attaches its trigger again after every render" and "only when the popover's open state or ids change" do not hold for an inline onOpenChange, which still re-attaches the trigger on every render; keep those callbacks stable or narrow the wording.
  • No test reproduces the "Maximum update depth exceeded" crash the release note names, and on the base a trigger whose text changes on every re-render settles without it; drop the sentence or add a test that reproduces it.

The open inline threads carry the detail, including two non-blocking comment suggestions at Popover.tsx:603-604 and :943.

Claims and files checked

Review mode: same-head; reason: none

  • Claim: before the change, every render detached and re-attached the trigger and set Popover state. Verified: the new test fails on the base (7 click attaches against 2), and usePopover returns a new object each render.
  • Claim: a trigger whose text changes between renders can crash the page with an update-depth error. Not shown: no test reproduces it, and a base run with the text changing on 20 re-renders logs no such error.
  • Claim: after the change the trigger re-attaches only when the open state, ids or role change. False for an inline onOpenChange (1 to 6 click attaches over five re-renders).
  • Claim: the public usePopover return stays unmemoized, so no identity contract is added. Verified (usePopover.tsx returns a fresh object).
  • Claim: the text update keeps an unchanged text. Verified, though React already skips an equal set, so it changes nothing.
  • Claim: no API, visual or interaction change. API and visuals verified unchanged; interaction false for a replaced trigger (first finding).
  • Claim: the new test fails on the test-only commit, passes on the fix, and fails if the effects depend on the whole popover object again. Verified.
  • Claim: the existing Popover suites pass. Verified (8 files, 174 tests).
  • Claim: DropdownMenu uses usePopover, not Popover.tsx, so its interaction-test timeout is outside this change. Verified for the import; the flake's run counts were not rerun.
  • Claim: product teams hit the crash with documented usage. Not verifiable from the repository.
  • Release note: no re-attach after every render, and re-attach only on open state or ids. False for an inline onOpenChange. The update-depth loop: not shown.
  • File .changeset/popover-trigger-attach-once.md: second and third findings.
  • File packages/core/src/Popover/Popover.attachOnce.test.tsx: clear; it fails on the base and passes on the head, but covers neither node replacement nor an inline onOpenChange.
  • File packages/core/src/Popover/Popover.tsx: first and second findings, plus the two non-blocking comment suggestions.

Automated review (maintainer link)

Comment thread packages/core/src/Popover/Popover.tsx Resolved
Comment thread packages/core/src/Popover/Popover.tsx Resolved
Comment thread packages/core/src/Popover/Popover.tsx Resolved
Comment thread packages/core/src/Popover/Popover.tsx Resolved
Comment thread packages/core/src/Popover/Popover.tsx Resolved
…one attached

The narrowed dependencies stopped a replaced trigger from being attached: a
swapped or remounted button, or a new button behind anchorRef. One layout
check now runs after every commit and attaches again only when the anchor,
the button or attachTrigger changed. onOpenChange is read through a
committed ref, so an inline callback no longer causes a re-attach. The
release note now says only what the change does.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec b02b7ad

Two plain buttons in the same place reuse one element, so the earlier test
did not swap the element. Two component types mount a new one.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec cce34ce

@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 trigger now attaches once per element, and swapped or remounted triggers stay attached, but two points need fixing first:

  • Miss: a sheet Popover without label keeps its old name when the trigger's text changes while the sheet is open (Popover.tsx:945-948, :1015-1022), so it no longer matches the trigger as DEC-8 requires; re-read the trigger text in the per-commit check, set it only when it differs, and add a test.
  • The release note says the trigger re-attaches "only when the trigger element, or the open state or ids the trigger shows, change", but toggling isEnabled or hasAutoFocus re-attaches too; reword it to what the code does.

The comment at Popover.tsx:999-1001 could be split into shorter sentences, and the replaced-trigger tests could also assert that a click opens the popover; neither blocks.

Claims and files checked

Review mode: same-head; reason: none

  • Claim: re-renders no longer detach and re-attach the trigger or set state: verified (the attach-once tests fail on the base, 7 attaches against 2, and pass on the head).
  • Claim: the trigger re-attaches only when its element, open state or ids change: false (isEnabled and hasAutoFocus toggles re-attach).
  • Claim: a swapped or remounted trigger is still attached: verified (replaced-trigger tests; a click on each opens the popover).
  • Claim: an inline onOpenChange no longer causes a re-attach: verified (test; one attach across five re-renders).
  • Claim: a patch release of core: verified (no public API change).
  • Claim: the base re-attached and set state on every render because the effects and click handler depended on the per-render popover object: verified (base dependencies; 2 to 7 attaches).
  • Claim: a render that changes nothing the trigger shows does no attach work: false (same isEnabled and hasAutoFocus evidence).
  • Claim: one per-commit check re-attaches only when the anchor, button or attachTrigger changes: verified (Popover.tsx:1006-1055).
  • Claim: the click handler reads stable members and onOpenChange goes through a committed ref: verified (Popover.tsx:566-575, :874-909).
  • Claim: the public usePopover return stays unmemoized: verified (usePopover.tsx is unchanged).
  • Claim: the ordinary re-render rule of the React runtime architecture governs the fix: verified at the current spec.
  • Claim: only Popover.tsx changes in source: verified.
  • Claim: no API, visual or interaction change: false (an open unlabeled sheet's name stops following the trigger text).
  • Claim: the new tests fail on the base for stable props and an inline onOpenChange, and pass on the head: verified.
  • Claim: replaced triggers get aria-haspopup and the click listener, and the existing Popover suites pass: verified (8 suites, 178 tests).
  • Claim: the tests fail if the attach runs every render again, or stops following the element: verified (red on the base; the three replaced-trigger tests fail with the earlier head's code).
  • Claim: no test reproduces the reported crash: consistent with the tests.
  • Claim: the checklist's single defect, no tagalong and no hidden public API: verified (no API rows, no tagalong).
  • Claim: DropdownMenu uses usePopover, not Popover.tsx: verified.
  • Claim: the unrelated DropdownMenu interaction test passed 25 of 25 runs, and later test results will follow: not checked (outside this change).
  • File .changeset/popover-trigger-attach-once.md: finding (overstated "only when").
  • File packages/core/src/Popover/Popover.tsx: finding (stale sheet name); non-blocking comment wording.
  • File packages/core/src/Popover/Popover.attachOnce.test.tsx: clear, consistent with Popover.tsx; non-blocking click assertion.

Automated review (maintainer link)

Comment thread packages/core/src/Popover/Popover.tsx Resolved
Comment thread packages/core/src/Popover/Popover.tsx Resolved
A sheet with no label is named by its trigger's text. The check now reads
that text when nothing else changed, and sets it only when it changed, so
the sheet's name follows the trigger and an unchanged render sets no state.
The release note says what the change does.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 44980d6

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 1c7d2c6

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 268b7ec

@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 attach-once fix works and every earlier finding is resolved, but one regression remains in the trigger detach, and the description needs one fix.

  • Miss: when a Popover's children change from an element to a render function, detachTrigger (Popover.tsx:995-996) clears the layer anchor that the new render-prop trigger has just registered, so the popover opens with no anchor and is not placed against its trigger; clear anchorElementRef and call setPopoverTrigger(null) only while anchorElementRef.current === attached.anchor, and add a test for that swap.
  • The description cites the crash report as #185, which on this repository links to an unrelated closed issue, so link the actual report or drop the number.

Non-blocking: remove the unused eslint-disable-next-line at Popover.tsx:1027, and consider having the replaced-trigger tests click the new trigger.

Claims and files checked

Review mode: incremental; reason: none

  • changed rules (0): none
  • Release note, no detach, re-attach or state update on a re-render with the same props and trigger: verified (attach-once tests fail on the base, 7 attaches against 2, and pass on the head; five re-renders take 5 commits, against 7 on the base).
  • Release note, a swapped or remounted trigger stays attached: verified for component swaps, key remounts and a remounted anchorRef button (tests); false for a swap to a render-function trigger (first finding).
  • Release note, an unlabeled sheet follows its trigger's text: verified (new presentation test; it fails with the previous head's code).
  • Description, the crash report reference: false (second finding).
  • Description, the base detached, re-attached and set state on every render: verified (both base Effects depend on the whole popover object, which is new each render).
  • Description, the Chromium page-loop reproduction: not rerun; the description does not claim this change stops that loop.
  • Description, one layout check attaches again only when the anchor, the button or attachTrigger changes: verified (its list of what changes attachTrigger omits enabled state, presentation and auto-focus).
  • Description, the click handler reads stable members and onOpenChange goes through a committed ref: verified (inline-callback test).
  • Description, the public usePopover return is not memoized: verified (usePopover.tsx is unchanged).
  • Description, no API, visual or interaction change and a replaced trigger is attached as before: no API rows in any compared package; false for the render-function swap (first finding).
  • Description, the new tests fail on the base, pass on the head, and catch a regression: verified (base run; the first head's code fails the replaced-trigger tests).
  • Description, existing suites pass and DropdownMenu does not render Popover.tsx: verified (37 files, 1,424 tests; import graph); the 25-run tallies were not rerun.
  • .changeset/popover-trigger-attach-once.md: clear.
  • packages/core/src/Popover/Popover.attachOnce.test.tsx: clear (non-blocking: no click on replaced triggers).
  • packages/core/src/Popover/Popover.tsx: first finding; non-blocking unused lint directive and a comment that restates a type.
  • packages/core/src/Popover/PopoverPresentation.test.tsx: clear.

Automated review (maintainer link)

Comment thread packages/core/src/Popover/Popover.tsx Resolved
Comment thread packages/core/src/Popover/Popover.tsx Resolved
…anchor

When children change from an element to a render function, the new trigger's
ref registers it as the anchor before the old trigger detaches. The detach
now clears the anchor only while it is still the one the check set. Also
drops an unused lint directive.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 39fa005

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 7c286e4

…re it reads the anchor

A closed trigger names no anchor, so the test now opens the popover and
checks that it anchors to the render-prop trigger. It guards the switch; it
does not separate the earlier head, whose anchor cleanup leaves no trace in
jsdom.

@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. Popover's trigger attaches through the shared useAttachment lifecycle, and the attach-once fix, every trigger path and the release note check out; one description sentence is left.

  • The Testing section still says the interaction-timing floor fails outside this change because main cannot absorb one more untimed spec, but on this head 142 of 143 interaction specs are timed and the floor test in .github/scripts/playwright-legs.test.mjs passes, so please drop the floor from that sentence.

Non-blocking: the open inline notes on the replaced-trigger tests (they never click the new trigger) and on useAttachment's ref parameter name still apply.

Claims and files checked

Review mode: same-head; reason: none

  • Release note, a Popover whose props and trigger stay the same no longer re-attaches its trigger on re-render: verified (the attach-once tests fail on the base, 7 attaches against 2, and pass on this head).
  • Release note, a swapped, remounted or render-function trigger stays attached and the popover anchors to it: verified (a test for each passes, and in Chromium the popover opens 4 px under the render-function trigger, pixel-identical to the base).
  • Description, the reported nested-update loop comes from the page's own width check, with or without a Popover: not rerun; the change does not claim to stop that loop.
  • Description, the base re-attached the trigger and re-read its text on every render because its Effects and click handler depended on the whole popover object: verified (the base's two attach Effects and click handler list popover).
  • Description, a sheet with no label still follows its trigger's text: verified (the open-sheet rename test passes).
  • Description, a trigger text that changes on every render still re-renders each time: verified (Popover.tsx:1058-1068 sets state whenever the text changed).
  • Description, the anchor and the trigger button attach through useAttachment, keyed on the trigger ref and attachTrigger, with a function form for nodes no ref holds: verified (Popover.tsx:1018-1054, hooks/useAttachment.ts:27-28 and :82-84).
  • Description, the release clears the anchor only while it owns it: verified (Popover.tsx:1023-1029, and the Chromium check).
  • Description, stable click-handler members and a committed onOpenChange stop an inline callback from re-attaching: verified (the inline-callback test fails on the base and passes on this head).
  • Description, useAttachment stays internal and the public usePopover return is not memoized: verified.
  • Description, no API, visual or interaction change: verified (the API generator lists no rows; before and after frames are identical).
  • Description, test results against main's Popover.tsx: verified (the two attach-once tests fail 7 against 2 and the replaced-trigger cases pass); the results against earlier heads were not rerun.
  • Description, the 13 useAttachment importers and their callers pass: the 13 importers verified, and the Popover and hooks suites pass (73 files, 1,433 tests); the per-row counts and the 228-file total were not recounted.
  • Description, the new browser spec passes and fails where the release cleared the anchor: its assertions verified with a Chromium check; the spec itself was not run.
  • Description, preflight passes, including strict lint, the 7 attach-once tests and the 34 presentation tests: verified for strict lint on the changed files and those tests; the other steps were not rerun.
  • Description, the interaction-timing floor sits outside this change and main cannot absorb one more untimed spec: false on this head (the blocking point above).
  • Description, the 4 px Switch case sits outside this change: verified (the Switch story's import graph reaches neither changed source file); the case itself was not rerun.
  • Description, first-load deltas (docs +0, form +9, menu −1, table −1 B gzip), with only the form page reaching the hook: verified to within 2 B (this head against its base: +0, +9, +1 and +0 B).
  • Description, the timed-out DropdownMenu sheet test runs useAttachment through the mobile keyboard with a ref, not Popover.tsx: verified (keyboard/useMobileKeyboard.ts:230 and :243); the repeated-run tallies were not rerun.
  • Description, public text holds no internal context: verified.
  • .changeset/popover-trigger-attach-once.md: clear.
  • apps/storybook/stories/PopoverTriggerSwitch.stories.tsx: clear.
  • packages/core/src/Popover/Popover.attachOnce.test.tsx: clear; non-blocking test note.
  • packages/core/src/Popover/Popover.tsx: clear.
  • packages/core/src/Popover/PopoverPresentation.test.tsx: clear.
  • packages/core/src/Popover/__tests__/PopoverTriggerSwitch.interaction.browser.spec.ts: clear (the floor passes with it untimed).
  • packages/core/src/hooks/__tests__/useAttachment.test.tsx: clear.
  • packages/core/src/hooks/useAttachment.ts: clear; non-blocking naming note.

Automated review (maintainer link)

@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: CI finished on this head with no failing check.

Popover's trigger now attaches through the shared useAttachment lifecycle, so re-renders with the same props and trigger no longer re-attach it, while swapped, remounted and render-function triggers stay attached; the new Chromium spec and the attach-once tests pass in this head's CI.

Non-blocking:

  • The Testing section says every preflight step passes, but the Switch case it mentions has a strict check (toBeLessThan(4)), so reading exactly 4 px is a failure; saying it failed once, outside this change, would read plainly.
  • The replaced-trigger tests never click the new trigger, and useAttachment's first parameter is still named ref (see the open inline notes).
Claims and files checked

Review mode: same-head; reason: none

  • Release note, a Popover whose props and trigger stay the same no longer re-attaches its trigger on re-render: verified (the attach-once tests fail on the base, 7 attaches against 2, and pass on this head).
  • Release note, a swapped, remounted or render-function trigger stays attached and the popover anchors to it: verified (a test for each passes, and in Chromium the popover opens 4 px under the render-function trigger, as on the base).
  • Title, a children-mode trigger attaches only when what it reads changes: verified (the attachment is keyed on the trigger element and on attachTrigger, whose inputs are what the trigger shows).
  • Description, the reported nested-update loop comes from the page's own width check, with or without a Popover: not rerun; the change does not claim to stop that loop.
  • Description, the base re-attached the trigger and re-read its text on every render because its Effects and click handler depended on the whole popover object: verified (the base's two attach Effects and click handler list popover).
  • Description, product teams have no workaround in app code: context, not checked.
  • Description, the anchor and the trigger button attach through useAttachment, keyed on the trigger ref and attachTrigger, with a function form for nodes no ref holds: verified (Popover.tsx:1018-1054, hooks/useAttachment.ts:27-28 and :82-84).
  • Description, the release clears the anchor only while it owns it: verified (Popover.tsx:1025-1028, and the Chromium check).
  • Description, stable click-handler members and a committed onOpenChange stop an inline callback from re-attaching: verified (the inline-callback test fails on the base and passes on this head).
  • Description, a sheet with no label still follows its trigger's text: verified (the open-sheet rename test passes, here and in this head's CI).
  • Description, a trigger text that changes on every render still re-renders each time: verified (Popover.tsx:1058-1068 sets state whenever the text changed).
  • Description, useAttachment stays internal and the public usePopover return is not memoized: verified.
  • Description, no API, visual or interaction change: verified (no public API rows; before and after frames are identical).
  • Description, a swapped, key-remounted or anchorRef-remounted trigger gets aria-haspopup and the click listener: verified (the tests check the attribute, and each trigger opens on click at this head).
  • Description, test results against main's Popover.tsx: verified (the two attach-once tests fail 7 against 2, and the replaced-trigger cases pass); the results against earlier heads were not rerun.
  • Description, the 13 useAttachment importers and their callers pass: the 13 importers verified, and the Popover and hooks suites pass; the per-row counts and the 228-file total were not recounted.
  • Description, the new browser spec passes, and failed where the release cleared the anchor: passes in this head's CI Chromium run; the earlier-head runs were not rerun.
  • Description, preflight passes, including strict lint, the 7 attach-once tests and the 34 presentation tests: strict lint passes in this head's CI and the presentation suite runs 34 tests there; the other steps were not rerun.
  • Description, one Switch interaction case outside this change met its 4 px limit once: outside this change verified (its import graph reaches neither changed source file); that check is strict, so the reading is a failure, which "every step passes" leaves unsaid; the 1-of-40 and 0-of-40 tallies were not rerun.
  • Description, this head merges main with interaction times for every existing spec, and the timing floor passes with 142 of 143 specs timed: verified (only the new spec is untimed; 99.3 % against a 90 % floor; the floor test passes in this head's CI).
  • Description, first-load deltas (docs +0, form +9, menu −1, table −1 B gzip), with only the form page reaching the hook: verified to within 2 B (+0, +9, +1 and +0 B measured).
  • Description, the timed-out DropdownMenu sheet test reaches useAttachment through the mobile keyboard with a ref, not Popover.tsx: verified (keyboard/useMobileKeyboard.ts:230 and :243); the repeated-run tallies were not rerun.
  • Description, public text holds no internal context: verified.
  • .changeset/popover-trigger-attach-once.md: clear.
  • apps/storybook/stories/PopoverTriggerSwitch.stories.tsx: clear.
  • packages/core/src/Popover/Popover.attachOnce.test.tsx: clear; non-blocking test note.
  • packages/core/src/Popover/Popover.tsx: clear.
  • packages/core/src/Popover/PopoverPresentation.test.tsx: clear.
  • packages/core/src/Popover/__tests__/PopoverTriggerSwitch.interaction.browser.spec.ts: clear (passes in CI; the floor passes with it untimed).
  • packages/core/src/hooks/__tests__/useAttachment.test.tsx: clear.
  • packages/core/src/hooks/useAttachment.ts: clear; non-blocking naming note.

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as ready for review November 21, 2026 15:11
@cixzhang
cixzhang marked this pull request as draft November 22, 2026 18:46
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec ce23a88

@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: two sentences in the description do not match this head; the code is unchanged since the last review and still checks out.

  • Regression: the Testing section says the merged timing record covers every existing interaction spec and that only the new PopoverTriggerSwitch spec is untimed (142 of 143), but at this head 10 of 152 interaction specs have no recorded time (this one and nine from main) and the floor passes only because it counts the 142 specs the record lists, so please reword it, for example: "the interaction-timing floor passes here: it counts the 142 specs the timing record lists, all timed; ten newer specs, this one and nine from main, have no time yet."
  • Miss: the "Reach of the shared change" section says Popover's children-mode trigger is the only caller that passes a function to useAttachment, but anchorRef mode passes the same findTriggerAnchor and findTrigger functions (Popover.tsx lines 987-1054), so <Popover anchorRef> callers such as the rich text editor's link popover run the changed code too; please say instead "Popover is the only caller that passes a function: its children-mode and anchorRef triggers attach through it; a render-prop trigger keeps its ref callback."

The attach-once tests fail on the current base (7 attaches against 2) and pass here; CI has not run on this head because it is a draft. The earlier non-blocking notes still apply: the Switch sentence in the Testing section, the replaced-trigger tests that never click, and useAttachment's ref parameter name.

Claims and files checked

Review mode: same-head; reason: none

  • changed rules (0): none
  • Release note, a Popover whose props and trigger stay the same no longer re-attaches its trigger on re-render: verified (the attach-once tests fail on the base, 7 attaches against 2, and pass on this head).
  • Release note, a swapped, remounted or render-function trigger stays attached and the popover anchors to it: verified (a test for each passes, and in Chromium the popover opens 4 px under the render-function trigger, as on the base).
  • Title, a children-mode trigger attaches only when what it reads changes: verified (the attachment is keyed on the trigger element and on attachTrigger, whose inputs are what the trigger shows).
  • Description, the reported nested-update loop comes from the page's own width check: not rerun; the change does not claim to stop that loop.
  • Description, the base re-attached the trigger and re-read its text on every render because its Effects and click handler depended on the whole popover object: verified.
  • Description, product teams have no workaround in app code: context, not checked.
  • Description, the anchor and the trigger button attach through useAttachment, with a function form for nodes no ref holds: verified (Popover.tsx:1018-1054, hooks/useAttachment.ts:27-28 and :82-84).
  • Description, the release clears the anchor only while it owns it: verified (Popover.tsx:1023-1029, and the Chromium check).
  • Description, stable click-handler members and a committed onOpenChange stop an inline callback from re-attaching: verified (the inline-callback test fails on the base and passes here).
  • Description, a sheet with no label still follows its trigger's text: verified (the open-sheet rename test passes here).
  • Description, a trigger text that changes on every render still re-renders each time: verified (Popover.tsx:1056-1068 sets state whenever the text changed).
  • Description, useAttachment stays internal and the public usePopover return is not memoized: verified.
  • Description, no API, visual or interaction change: verified (no public API rows; before and after frames are identical).
  • Description, a swapped, key-remounted or anchorRef-remounted trigger gets aria-haspopup and the click listener: the attribute verified by the tests here; the click listener is not covered by them (non-blocking note).
  • Description, test results against main's Popover.tsx: verified (the two attach-once tests fail 7 against 2, and the replaced-trigger cases pass); results against earlier heads not rerun.
  • Description, the 13 useAttachment importers and their callers pass: the 13 importers verified, and the Popover, hooks, gestures, Toolbar and keyboard suites pass here; the per-row counts and the 228-file total not recounted.
  • Description, the new browser spec passes, and failed where the release cleared the anchor: not run on this head (no CI on a draft); a Chromium probe of its story shows the same anchor on base and head.
  • Description, preflight passes, including strict lint, the 7 attach-once tests and the 34 presentation tests: strict lint on the changed files and both suites pass here; the interaction suite and the pre-review script not rerun.
  • Description, one Switch interaction case outside this change met its 4 px limit once: outside this change verified; the check is strict, so that reading is a failure (non-blocking note).
  • Description, the timing record covers every existing spec and only the new spec is untimed (142 of 143): false at this head (10 of 152 untimed; the floor passes on the 142 recorded specs).
  • Description, first-load deltas (docs +0, form +9, menu −1, table −1 B gzip): verified to within 2 B (+0, +9, −2 and +1 B measured).
  • Description, the timed-out DropdownMenu sheet test reaches useAttachment through the mobile keyboard with a ref, not Popover.tsx: verified (keyboard/useMobileKeyboard.ts:230 and :243).
  • Description, reach: useAttachment and useAttachmentPair accept a function, and a caller that passes a ref takes the same path as before: verified (hooks/useAttachment.ts:82-84; the 12 other importers pass refs).
  • Description, reach: Popover's children-mode trigger is the only caller that passes a function: false (Popover passes the same functions in anchorRef mode, Popover.tsx:987-1054).
  • Description, reach: DropdownMenu builds on usePopoverInternal and does not run Popover's trigger code: verified (DropdownMenu.tsx:51).
  • Description, public text holds no internal context: verified.
  • .changeset/popover-trigger-attach-once.md: clear.
  • apps/storybook/stories/PopoverTriggerSwitch.stories.tsx: clear.
  • packages/core/src/Popover/Popover.attachOnce.test.tsx: clear; non-blocking test note.
  • packages/core/src/Popover/Popover.tsx: clear.
  • packages/core/src/Popover/PopoverPresentation.test.tsx: clear.
  • packages/core/src/Popover/__tests__/PopoverTriggerSwitch.interaction.browser.spec.ts: clear (not run here; untimed, which the floor allows).
  • packages/core/src/hooks/__tests__/useAttachment.test.tsx: clear.
  • packages/core/src/hooks/useAttachment.ts: clear; non-blocking naming note.

Automated review (maintainer link)

@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; marking it ready for review starts CI.

The Testing section's timing sentence and the Reach section's caller sentence now match the code, and the attach-once tests fail on the current base (7 attaches against 2) and pass here. Three non-blocking notes remain: the Switch sentence in the Testing section reads "every step passes" beside a case that failed its strict 4 px check, the replaced-trigger tests never click the new trigger, and useAttachment's first parameter is still named ref.

Claims and files checked

Review mode: same-head; reason: none

  • changed rules (0): none
  • Release note: a Popover whose props and trigger stay the same no longer re-attaches its trigger on re-render: verified (the attach-once tests fail on the current base, 7 attaches against 2, and pass here).
  • Release note: a swapped, remounted or render-function trigger stays attached and the popover anchors to it: verified (a test for each passes; in Chromium the popover opens 4 px under the render-function trigger, as on the base).
  • Title: a children-mode trigger attaches only when what it reads changes: verified (the attachment is keyed on the trigger element and on attachTrigger, whose inputs are what the trigger shows).
  • Description: the reported nested-update loop comes from the page's own width check and fires without a Popover too: context about a page outside this repository, not checkable against the code; the change does not claim to stop that loop.
  • Description: the base re-attached the trigger and re-read its text on every render because its Effects and click handler listed the whole popover object: verified (the base Effects list popover, which usePopover returns as a new object each render).
  • Description: product teams have no workaround in app code: context, not checked.
  • Description: the anchor and the trigger button attach through useAttachment, with a function form for nodes no ref holds: verified (Popover.tsx:1018-1054, hooks/useAttachment.ts:27-28 and :82-84).
  • Description: the release clears the anchor only while it owns it: verified (Popover.tsx:1023-1029, and the Chromium check).
  • Description: stable click-handler members and a committed onOpenChange stop an inline callback from re-attaching: verified (the inline-callback test fails on the base and passes here).
  • Description: a sheet with no label still follows its trigger's text: verified (the open-sheet rename test passes here).
  • Description: a trigger text that changes on every render still re-renders each time: verified (Popover.tsx:1063-1066 sets state whenever the text changed).
  • Description: useAttachment stays internal and the public usePopover return is not memoized: verified (no package entry re-exports it; usePopover.tsx:1041 returns an object literal).
  • Description: no API, visual or interaction change: verified (no public API rows; the before and after frames are identical).
  • Description: an Effect is still the tool because the trigger is the caller's element, which no Popover ref callback sees: verified (both attachments sync DOM listeners and ARIA after commit and release them).
  • Description: a swapped, key-remounted or anchorRef-remounted trigger gets aria-haspopup and the click listener: verified (the tests check the attribute, and attachTrigger sets it and adds the listener in one call, Popover.tsx:929-958; the tests do not click, a non-blocking note).
  • Description: results against main's Popover.tsx: verified (the two attach-once tests fail 7 against 2, the replaced-trigger and DEC-8 cases pass; the bounded-commit test also fails there).
  • Description: results against an earlier head of this pull request: verified (the inline-callback test and the three replaced-trigger tests fail there, and the DEC-8 case fails on the commit before its fix).
  • Description: the 13 useAttachment importers and their callers pass: verified in substance (13 importers; the Popover, hooks, gestures, Toolbar, Lightbox, Carousel and keyboard suites and Lab's media marker test pass here, 132 files); the per-row counts are the author's tally, not recounted.
  • Description: the new browser spec passes, and failed where the release cleared the anchor: not run on this head (CI does not run on a draft); a Chromium probe of its story shows the same anchor on base and head.
  • Description: pnpm preflight --browser passes, including strict lint, the attach-once tests and the presentation tests: strict lint on the changed files and both suites pass here; the interaction suite and the pre-review script not rerun.
  • Description: one Switch interaction case outside this change met its 4 px limit once: outside this change verified (the Switch story's import graph reaches neither changed source file); the check is strict, so that reading is a failure (non-blocking wording note).
  • Description: the timing floor counts the 142 specs the record lists, all timed, and ten newer specs have no time yet: verified (152 interaction specs; the 142 recorded are timed; 10 untimed, this one and nine from main).
  • Description: first-load deltas (docs +0, form +9, menu −1, table −1 B gzip): verified to within 2 B (+0, +9, −2 and +1 B measured, at equal minified sizes apart from form's +25 B).
  • Description: the timed-out DropdownMenu sheet test reaches useAttachment through the mobile keyboard with a ref, not Popover.tsx: verified (keyboard/useMobileKeyboard.ts:230 and :243; DropdownMenu imports usePopoverInternal).
  • Description, reach: useAttachment and useAttachmentPair accept a function, and a caller that passes a ref takes the same path as before: verified (hooks/useAttachment.ts:82-84; the 12 other importers pass refs).
  • Description, reach: Popover is the only caller that passes a function, through its children-mode and anchorRef triggers, and a render-prop trigger keeps its ref callback: verified (Popover.tsx:1018-1054, :867-874).
  • Description, reach: DropdownMenu builds on usePopoverInternal and does not run Popover's trigger wiring: verified (DropdownMenu.tsx:51).
  • Description: public text holds no internal context: verified.
  • .changeset/popover-trigger-attach-once.md: clear.
  • apps/storybook/stories/PopoverTriggerSwitch.stories.tsx: clear.
  • packages/core/src/Popover/Popover.attachOnce.test.tsx: clear; non-blocking test note.
  • packages/core/src/Popover/Popover.tsx: clear.
  • packages/core/src/Popover/PopoverPresentation.test.tsx: clear.
  • packages/core/src/Popover/__tests__/PopoverTriggerSwitch.interaction.browser.spec.ts: clear (not run here; untimed, which the floor allows).
  • packages/core/src/hooks/__tests__/useAttachment.test.tsx: clear.
  • packages/core/src/hooks/useAttachment.ts: clear; non-blocking naming note.

Automated review (maintainer link)

The swapped, key-remounted and anchorRef-remounted trigger tests now
click the new trigger and check it opens the popover, so they cover its
click listener. useAttachment's first parameter is a target, a ref or a
function, so it is named for that.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec e6ad79b

@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; marking it ready for review starts CI.

The new commit makes the replaced-trigger tests click the new trigger and renames useAttachment's first parameter to target, and the description's Switch sentence now names the failing case, so the last review's notes are closed; the attach-once tests still fail on the current base (7 attaches against 2) and pass here. One non-blocking note: useAttachmentPair's firstRef and secondRef parameters, and the "nodes the refs hold" wording in the file header and its JSDoc, could follow the same rename.

Claims and files checked

Review mode: incremental; reason: none

  • changed rules (0): none
  • Release note: a Popover whose props and trigger stay the same no longer re-attaches its trigger on re-render: verified (the attach-once tests fail on the current base, 7 attaches against 2, and pass here).
  • Release note: a swapped, remounted or render-function trigger stays attached and the popover anchors to it: verified (a test for each passes and now clicks the new trigger; in Chromium the popover opens 4 px under the render-function trigger, as on the base).
  • Title: a children-mode trigger attaches only when what it reads changes: verified (the attachment is keyed on the trigger element and on attachTrigger, whose inputs are what the trigger shows).
  • Description: the reported nested-update loop comes from the page's own width check and fires without a Popover too: context about a page outside this repository, not checkable against the code; the change does not claim to stop that loop.
  • Description: the base re-attached the trigger and re-read its text on every render because its Effects and click handler listed the whole popover object: verified (the base Effects list popover, a new object each render).
  • Description: product teams have no workaround in app code: context, not checked.
  • Description: the anchor and the trigger button attach through useAttachment, with a function form for nodes no ref holds: verified (Popover.tsx:1018-1054, hooks/useAttachment.ts:27-28 and :82-84).
  • Description: the release clears the anchor only while it owns it: verified (Popover.tsx:1023-1029, and the Chromium check).
  • Description: stable click-handler members and a committed onOpenChange stop an inline callback from re-attaching: verified (the inline-callback test fails on the base and passes here).
  • Description: a sheet with no label still follows its trigger's text: verified (the open-sheet rename test passes here).
  • Description: a trigger text that changes on every render still re-renders each time: verified (Popover.tsx:1063-1066 sets state whenever the text changed).
  • Description: useAttachment stays internal and the public usePopover return is not memoized: verified (no package entry re-exports it; the API comparison lists no change).
  • Description: no API, visual or interaction change: verified (no public API rows; the before and after frames are identical).
  • Description: an Effect is still the tool because the trigger is the caller's element, which no Popover ref callback sees: verified (both attachments sync DOM listeners and ARIA after commit and release them).
  • Description: a swapped, key-remounted or anchorRef-remounted trigger gets aria-haspopup and the click listener: verified (the tests check the attribute, then click the new trigger and see it open).
  • Description: Popover.attachOnce.test.tsx has 7 tests and passes with the function-form and DEC-8 tests: verified (7 tests; all pass here).
  • Description: against the base's Popover.tsx, the two attach-once tests fail (7 against 2) and the replaced-trigger and DEC-8 cases pass: verified (the bounded-commit test also fails there).
  • Description: against an earlier head of this pull request, the inline-callback test and the three replaced-trigger tests fail, and the DEC-8 case fails on the commit before its fix: verified at the previous revision by running those commits; the code they test is unchanged since.
  • Description: the 13 useAttachment importers and their callers pass: verified in substance at the previous revision (13 importers; their suites passed); the per-row counts are the author's tally, not recounted.
  • Description: the new browser spec passes, and failed where the release cleared the anchor: not run on this head (CI does not run on a draft); a Chromium probe of its story shows the same anchor on base and head.
  • Description: pnpm preflight --browser passes apart from one Switch interaction case outside this change, including strict lint and the Popover suites: strict lint on the changed files and the Popover and hooks suites pass here; the interaction suite and the pre-review script were not rerun.
  • Description: the Switch case is outside this change and does not reproduce (1 of 40 here, 0 of 40 on the base): outside this change verified (its story's import graph reaches neither changed source file); the rerun counts are the author's tally.
  • Description: the timing floor counts the 142 specs the record lists, all timed, and ten newer specs have no time yet: verified at the previous revision (152 interaction specs; 142 recorded and timed; 10 untimed); no spec or timing file changed since.
  • Description: first-load deltas (docs +0, form +9, menu −1, table −1 B gzip): verified to within 2 B at the previous revision (+0, +9, −2 and +1 B measured); the only source change since renames one parameter.
  • Description: the timed-out DropdownMenu sheet test reaches useAttachment through the mobile keyboard with a ref, not Popover.tsx: verified (DropdownMenu imports usePopoverInternal; the mobile keyboard passes a ref).
  • Description, reach: useAttachment and useAttachmentPair accept a function, and a caller that passes a ref takes the same path as before: verified (hooks/useAttachment.ts:82-84; the 12 other importers pass refs).
  • Description, reach: Popover is the only caller that passes a function, through its children-mode and anchorRef triggers, and a render-prop trigger keeps its ref callback: verified (Popover.tsx:1018-1054, :867-874).
  • Description, reach: DropdownMenu builds on usePopoverInternal and does not run Popover's trigger wiring: verified.
  • Description: public text holds no internal context: verified.
  • .changeset/popover-trigger-attach-once.md: clear.
  • apps/storybook/stories/PopoverTriggerSwitch.stories.tsx: clear.
  • packages/core/src/Popover/Popover.attachOnce.test.tsx: clear.
  • packages/core/src/Popover/Popover.tsx: clear.
  • packages/core/src/Popover/PopoverPresentation.test.tsx: clear.
  • packages/core/src/Popover/__tests__/PopoverTriggerSwitch.interaction.browser.spec.ts: clear (not run here; untimed, which the floor allows).
  • packages/core/src/hooks/__tests__/useAttachment.test.tsx: clear.
  • packages/core/src/hooks/useAttachment.ts: clear; non-blocking naming note.

Automated review (maintainer link)

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec c22685c

@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; marking it ready for review starts CI.

The new commit renames useAttachmentPair's parameters to firstTarget and secondTarget and updates its JSDoc, and the attach-once tests still fail on the current base (7 click-listener adds against 2) and pass here, while swapped, remounted, render-function and anchorRef triggers still attach and open. One non-blocking note: the file header's @output in hooks/useAttachment.ts, and the internal useAttachedNodes comments, still say "the nodes the refs hold", where "the nodes the targets find" would match.

Claims and files checked

Review mode: incremental; reason: none

  • changed rules (0): none
  • Release note: a Popover whose props and trigger stay the same no longer re-attaches its trigger on re-render: verified (the attach-once tests fail on the current base, 7 attaches against 2, and pass here).
  • Release note: a swapped, remounted or render-function trigger stays attached and the popover anchors to it: verified (a test for each clicks the new trigger and sees it open; in Chromium the popover opens 4 px under the render-function trigger, as on the base).
  • Title: a children-mode trigger attaches only when what it reads changes: verified (the attachment is keyed on the trigger element and on attachTrigger, whose inputs are what the trigger shows).
  • Description: the reported nested-update loop comes from the page's own width check and fires without a Popover too: context about a page outside this repository, not checkable against the code; the change does not claim to stop that loop.
  • Description: the base re-attached the trigger and re-read its text on every render because its Effects and click handler listed the whole popover object: verified (the base Effects list popover, a new object each render).
  • Description: product teams have no workaround in app code: context, not checked.
  • Description: the anchor and the trigger button attach through useAttachment, with a function form for nodes no ref holds: verified (Popover.tsx:1018-1054, hooks/useAttachment.ts:27-28 and :82-84).
  • Description: the release clears the anchor only while it owns it: verified (Popover.tsx:1023-1029, and the Chromium check).
  • Description: stable click-handler members and a committed onOpenChange stop an inline callback from re-attaching: verified (the inline-callback test fails on the base and passes here).
  • Description: a sheet with no label still follows its trigger's text: verified (the open-sheet rename test passes here).
  • Description: a trigger text that changes on every render still re-renders each time: verified (Popover.tsx:1063-1066 sets state whenever the text changed).
  • Description: useAttachment stays internal and the public usePopover return is not memoized: verified (no package entry re-exports it; the API comparison lists no change).
  • Description: no API, visual or interaction change: verified (no public API rows; the before and after frames of three stories are identical).
  • Description: an Effect is still the tool because the trigger is the caller's element, which no Popover ref callback sees: verified (both attachments sync DOM listeners and ARIA after commit and release them).
  • Description: a swapped, key-remounted or anchorRef-remounted trigger gets aria-haspopup and the click listener: verified (the tests check the attribute, then click the new trigger and see it open).
  • Description: Popover.attachOnce.test.tsx has 7 tests and passes with the function-form and open-sheet tests: verified (7 tests; all pass here).
  • Description: against the base's Popover.tsx, the two attach-once tests fail (7 against 2) and the replaced-trigger and open-sheet cases pass: verified (the bounded-commit test also fails there).
  • Description: against an earlier head of this pull request, the inline-callback test and three replaced-trigger tests fail, and the open-sheet case fails on the commit before its fix: verified at an earlier revision by running those commits; the code they test is unchanged since.
  • Description: the 13 useAttachment importers and their callers pass: verified for the importers' own suites here (Popover and hooks, Carousel, gestures, keyboard, Lightbox, Toolbar and BottomSheet all pass); the per-row caller counts are the author's tally, not recounted.
  • Description: the new browser spec passes, and failed where the release cleared the anchor: not run on this head (CI does not run on a draft); a Chromium probe of its story shows the same anchor on base and head.
  • Description: pnpm preflight --browser passes apart from one Switch interaction case outside this change: strict lint on the changed files and the Popover and hooks suites pass here; the interaction suite and the pre-review script were not rerun.
  • Description: the Switch case is outside this change and does not reproduce (1 of 40 here, 0 of 40 on the base): outside this change verified at an earlier revision (its story's import graph reaches neither changed source file, and neither file's imports changed since); the rerun counts are the author's tally.
  • Description: the timing floor counts the 142 recorded specs, all timed, and ten newer specs have no time yet: verified at an earlier revision; no spec or timing file changed since.
  • Description: first-load deltas (docs +0, form +9, menu −1, table −1 B gzip): verified to within 2 B at an earlier revision; the only source changes since rename internal parameters.
  • Description: the timed-out DropdownMenu sheet test reaches useAttachment through the mobile keyboard with a ref, not Popover.tsx: verified (DropdownMenu imports usePopoverInternal; the mobile keyboard passes a ref).
  • Description, reach: useAttachment and useAttachmentPair accept a function, and a caller that passes a ref takes the same path as before: verified (hooks/useAttachment.ts:82-84; the 12 other importers pass refs).
  • Description, reach: Popover is the only caller that passes a function, through its children-mode and anchorRef triggers, and a render-prop trigger keeps its ref callback: verified (Popover.tsx:1018-1054, :867-874).
  • Description, reach: DropdownMenu builds on usePopoverInternal and does not run Popover's trigger wiring: verified.
  • Description: public text holds no internal context: verified.
  • .changeset/popover-trigger-attach-once.md: clear.
  • apps/storybook/stories/PopoverTriggerSwitch.stories.tsx: clear.
  • packages/core/src/Popover/Popover.attachOnce.test.tsx: clear.
  • packages/core/src/Popover/Popover.tsx: clear.
  • packages/core/src/Popover/PopoverPresentation.test.tsx: clear.
  • packages/core/src/Popover/__tests__/PopoverTriggerSwitch.interaction.browser.spec.ts: clear (not run here).
  • packages/core/src/hooks/__tests__/useAttachment.test.tsx: clear.
  • packages/core/src/hooks/useAttachment.ts: clear; non-blocking header wording note.

Automated review (maintainer link)

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 1374221

@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: one unit-test shard of the new CI run on this head was still running at review time, and every other check that finished passed. The attach-once fix holds: the new tests fail on the current base (7 click-listener adds against 2) and pass here, and swapped, remounted, render-function and anchorRef triggers attach, open and anchor as before.

Nothing is needed from you. The earlier CI run's one failure, a Selector touch case (SelectorFocusableContainer.a11y.browser.spec.ts:124) whose story renders no Popover, passed in the new run on this head.

Claims and files checked

Review mode: same-head; reason: none

  • changed rules (0): none
  • Release note: a Popover whose props and trigger stay the same no longer detaches and re-attaches its trigger on re-render: verified (the attach-once tests fail on the current base, 7 attaches against 2, and pass here).
  • Release note: a trigger the caller swaps, remounts or turns into a render function stays attached, and the popover anchors to it: verified (each replaced-trigger test clicks the new trigger and sees it open; the browser spec passed in CI; the Chromium frames match the base pixel for pixel).
  • Title: a children-mode trigger attaches only when what it reads changes: verified (the attachment is keyed on the trigger element and on attachTrigger, Popover.tsx:1040-1054).
  • Description: the reported nested-update loop comes from the page's own width check and fires without a Popover too: context about a page outside this repository, not checkable here; the change does not claim to stop that loop.
  • Description: the base re-attached the trigger and re-read its text on every render because its Effects and click handler listed the whole popover object: verified (the removed Effects list popover, a new object each render).
  • Description: product teams have no workaround in app code: context, not checked.
  • Description: the anchor and the trigger button attach through useAttachment, which gains a function form for nodes no ref holds: verified (Popover.tsx:1018-1054, hooks/useAttachment.ts:27-28 and :82-84).
  • Description: the anchor release clears the anchor only while it owns it: verified (Popover.tsx:1023-1029; the render-prop switch test).
  • Description: a small layout check follows the trigger's text: verified (Popover.tsx:1056-1068 sets it only when it changed).
  • Description: stable click-handler members and a committed onOpenChange stop an inline callback from re-attaching: verified (the inline-callback test fails on the base, 7 against 2, and passes here).
  • Description: the public usePopover return is not memoized, so no new identity contract appears: verified (usePopover.tsx is untouched).
  • Description: useAttachment stays internal, with no API, visual or interaction change: verified (CI's API comparison lists 0 rows; no package entry reaches the module; the before and after frames of three stories are identical).
  • Description: an Effect is still the tool because the trigger is the caller's element, which no Popover ref callback sees: verified (both attachments sync DOM listeners and ARIA after commit and release them).
  • Description: a sheet with no label still follows its trigger's text: verified (the open-sheet rename test passes).
  • Description: a trigger whose text changes on every render still re-renders each time: verified (Popover.tsx:1063-1066 sets state whenever the text changed).
  • Description: Popover.attachOnce.test.tsx has 7 tests and passes with the function-form and open-sheet tests: verified (7 tests; all pass here).
  • Description: against the base's Popover.tsx, the two attach-once tests fail (7 against 2) and the replaced-trigger and open-sheet cases pass: verified (the bounded-commit test and the function-form test also fail there).
  • Description: against earlier heads of this pull request, the inline-callback test, three replaced-trigger tests, the open-sheet case and the browser spec failed: not rerun here; earlier reviews of this pull request found those defects at those heads.
  • Description: the 13 useAttachment importers and their callers pass: 13 importers confirmed and their suites pass here; the per-row counts are the author's tally, not recounted.
  • Description: the new browser spec passes in Chromium on built Storybook: verified (it passed in CI's Chromium interaction run at this head).
  • Description: an earlier preflight run passed apart from one Switch interaction case that does not reproduce: the author's run, not rerun; CI's lint, unit and interaction jobs passed at this head.
  • Description: the interaction-timing floor passes: verified (CI's node test job, which runs the floor check, passed at this head).
  • Description: first-load deltas on the four reference pages (form +25 / +9, the others within one byte of compression): verified (measured at this head: docs +0 / +0, form +25 / +9, menu +0 / +1, table +0 / +0 minified / gzip).
  • Description: the timed-out DropdownMenu sheet test reaches useAttachment only through the mobile keyboard's ref, not Popover.tsx: verified (DropdownMenu builds on usePopoverInternal; the mobile keyboard passes a ref).
  • Description, reach: a caller that passes a ref takes the same path as before; Popover is the only caller that passes a function, through its children-mode and anchorRef triggers, and a render-prop trigger keeps its ref callback: verified (the 12 other importers pass refs; Popover.tsx:867-874).
  • Description, reach: DropdownMenu builds on usePopoverInternal and does not run Popover's trigger wiring: verified.
  • Description: public text holds no internal context: verified.
  • .changeset/popover-trigger-attach-once.md: clear.
  • apps/storybook/stories/PopoverTriggerSwitch.stories.tsx: clear.
  • packages/core/src/Popover/Popover.attachOnce.test.tsx: clear.
  • packages/core/src/Popover/Popover.tsx: clear.
  • packages/core/src/Popover/PopoverPresentation.test.tsx: clear.
  • packages/core/src/Popover/__tests__/PopoverTriggerSwitch.interaction.browser.spec.ts: clear (passed in CI).
  • packages/core/src/hooks/__tests__/useAttachment.test.tsx: clear.
  • packages/core/src/hooks/useAttachment.ts: clear.

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as ready for review November 22, 2026 23:16
@cixzhang
cixzhang marked this pull request as draft November 22, 2026 23:47
@cixzhang
cixzhang marked this pull request as ready for review November 22, 2026 23:47
@cixzhang
cixzhang merged commit c1edfa4 into main Nov 23, 2026
243 of 245 checks passed
@github-actions
github-actions Bot deleted the fix/popover-children-attach-once branch November 23, 2026 06:06

This branch was successfully deployed

1 active deployment
Preview — 13742219 Deployed Nov 22, 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. lane:3 Astryx fix-loop lane 3 owns this

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant