Conversation
🦋 Changeset detectedLatest commit: 73d3763 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
There was a problem hiding this comment.
Pull request overview
This PR makes use of the browser Popover API in AnchoredOverlay opt-in (instead of implicitly enabling it whenever the CSS anchor positioning feature flag is active), aligning with the intent to treat popover behavior as an optional enhancement behind a feature flag.
Changes:
- Added a new
usePopover?: booleanprop toAnchoredOverlay, defaulting tofalse. - Gated Popover API wiring (
popoverTarget,popover="manual",id, andshowPopover()) behindusePopover && cssAnchorPositioning. - Added a changeset describing the behavioral change.
Show a summary per file
| File | Description |
|---|---|
| packages/react/src/AnchoredOverlay/AnchoredOverlay.tsx | Introduces usePopover and gates Popover API usage behind an explicit opt-in. |
| .changeset/hot-phones-sing.md | Records the change in release notes (currently marked as a patch bump). |
Copilot's findings
Comments suppressed due to low confidence (2)
packages/react/src/AnchoredOverlay/AnchoredOverlay.tsx:176
shouldUsePopoveris introduced, butonAnchorClickstill callsevent.preventDefault()based oncssAnchorPositioning. WithusePopover={false}and native CSS anchor positioning enabled, this will still prevent the anchor’s default action (e.g. link navigation) even though nopopoverTargetis set. Gate thepreventDefault()(and the callback deps) onshouldUsePopoverinstead ofcssAnchorPositioning.
const cssAnchorPositioningFlag = useFeatureFlag('primer_react_css_anchor_positioning')
const supportsNativeCSSAnchorPositioning = useRef(false)
const cssAnchorPositioning = cssAnchorPositioningFlag && supportsNativeCSSAnchorPositioning.current
// Only use Popover API when both CSS anchor positioning is enabled AND usePopover is true
const shouldUsePopover = cssAnchorPositioning && usePopover
const anchorRef = useProvidedRefOrCreate(externalAnchorRef)
packages/react/src/AnchoredOverlay/AnchoredOverlay.tsx:175
- This change makes Popover API usage opt-in, but there are no tests asserting the new default behavior (e.g. when the feature flag + native support are present,
usePopoverdefaults to off and nopopoverTarget/popover="manual"is applied; and whenusePopoveris on,showPopover()is invoked). Adding a focused unit test would help prevent regressions.
usePopover = false,
}) => {
const cssAnchorPositioningFlag = useFeatureFlag('primer_react_css_anchor_positioning')
const supportsNativeCSSAnchorPositioning = useRef(false)
const cssAnchorPositioning = cssAnchorPositioningFlag && supportsNativeCSSAnchorPositioning.current
// Only use Popover API when both CSS anchor positioning is enabled AND usePopover is true
const shouldUsePopover = cssAnchorPositioning && usePopover
- Files reviewed: 2/2 changed files
- Comments generated: 2
siddharthkp
left a comment
There was a problem hiding this comment.
Trust you with the implementation. Left a couple comments about direction and naming.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
👋 Hi from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/18924 |
Closes https://github.com/github/primer/issues/6556 & https://github.com/github/primer/issues/6557
Makes usage of the popover API opt-in, rather than have it on by default.
We may want to have the popover API enabled by default in the future, so the prop usage could be temporary.
Changelog
Changed
AnchoredOverlay|Overlayopt-inRollout strategy
Testing & Reviewing
Merge checklist