Skip to content

Make popover in AnchoredOverlay opt-in#7766

Open
TylerJDev wants to merge 7 commits intomainfrom
tylerjdev/make-popover-opt-in
Open

Make popover in AnchoredOverlay opt-in#7766
TylerJDev wants to merge 7 commits intomainfrom
tylerjdev/make-popover-opt-in

Conversation

@TylerJDev
Copy link
Copy Markdown
Member

@TylerJDev TylerJDev commented Apr 17, 2026

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

  • Make popover API usage in AnchoredOverlay | Overlay opt-in

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

Merge checklist

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 17, 2026

🦋 Changeset detected

Latest commit: 73d3763

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Minor

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

@TylerJDev TylerJDev added the Canary Release Apply this label when you want CI to create a canary release of the current PR label Apr 17, 2026
@github-actions github-actions Bot added staff Author is a staff member integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Apr 17, 2026
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Action required

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

To publish a canary release for integration testing, apply the Canary Release label to this PR.

@github-actions github-actions Bot requested a deployment to storybook-preview-7766 April 17, 2026 15:00 Abandoned
@github-actions github-actions Bot temporarily deployed to storybook-preview-7766 April 17, 2026 15:13 Inactive
@TylerJDev TylerJDev requested a review from siddharthkp April 17, 2026 18:35
@TylerJDev TylerJDev marked this pull request as ready for review April 17, 2026 18:35
@TylerJDev TylerJDev requested a review from a team as a code owner April 17, 2026 18:35
Copilot AI review requested due to automatic review settings April 17, 2026 18:35
@github-actions github-actions Bot temporarily deployed to storybook-preview-7766 April 17, 2026 18:38 Inactive
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?: boolean prop to AnchoredOverlay, defaulting to false.
  • Gated Popover API wiring (popoverTarget, popover="manual", id, and showPopover()) behind usePopover && 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

  • shouldUsePopover is introduced, but onAnchorClick still calls event.preventDefault() based on cssAnchorPositioning. With usePopover={false} and native CSS anchor positioning enabled, this will still prevent the anchor’s default action (e.g. link navigation) even though no popoverTarget is set. Gate the preventDefault() (and the callback deps) on shouldUsePopover instead of cssAnchorPositioning.
  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, usePopover defaults to off and no popoverTarget/popover="manual" is applied; and when usePopover is 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

Comment thread packages/react/src/AnchoredOverlay/AnchoredOverlay.tsx Outdated
Comment thread .changeset/hot-phones-sing.md
Comment thread packages/react/src/AnchoredOverlay/AnchoredOverlay.tsx Outdated
Copy link
Copy Markdown
Member

@siddharthkp siddharthkp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trust you with the implementation. Left a couple comments about direction and naming.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@primer-integration
Copy link
Copy Markdown

👋 Hi from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/18924

@primer-integration
Copy link
Copy Markdown

Integration test results from github/github-ui:

Passed  CI   Passed
Passed  VRT   Passed
Passed  Projects   Passed

All checks passed!

@TylerJDev TylerJDev requested a review from siddharthkp April 20, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Canary Release Apply this label when you want CI to create a canary release of the current PR integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm staff Author is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants