fix(react-headless-components-preview): share anchor-name across positioned popovers#36347
Open
micahgodbolt wants to merge 1 commit into
Open
Conversation
…tioned popovers usePositioning overwrote the trigger's anchor-name with a unique name per instance, so two popovers sharing one trigger (e.g. a hover Tooltip and a click Menu on the same button) clobbered each other — only the last writer stayed anchored and the other fell back to default placement. Append this instance's anchor name to the trigger's comma-separated anchor-name list and remove only our own on cleanup, preserving any author-set or sibling anchors. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
📊 Bundle size report
🤖 This report was generated against 19d82d85bda458b0af3fa4e0814bf3232fc78594 |
|
Pull request demo site: URL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes
Part of #36346.
What
usePositioningwrote a uniqueanchor-nameonto the trigger element and overwrote anything already there:When two positioned popovers share one trigger — e.g. a hover Tooltip + a click Menu on the same button — the two
usePositioninginstances clobber each other'sanchor-name.anchor-nameis single-valued here, so the last writer wins; the other popover'sposition-anchorpoints at a name that no longer exists and falls back to default (static / top‑left) placement.Rendered proof (menu closed, tooltip visible)
How
anchor-nameaccepts a comma-separated list. EachusePositioninginstance now appends its own name and removes only its own on cleanup, preserving any author-set or sibling anchors:Single-popover triggers are unchanged; N popovers per trigger now each resolve their own
position-anchor.Tests
Added two unit tests to
usePositioning.test.tsx:anchor-namecontains both distinct namesanchor-nameis preservedAll 19
usePositioningtests pass; Tooltip suite (16) unaffected.