AnchoredOverlay: Add settings for CSS anchor positioning#7964
Conversation
🦋 Changeset detectedLatest commit: e55eba7 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
Adds an opt-out mechanism for native CSS anchor positioning in AnchoredOverlay, and applies it to keep SelectPanel’s modal variant manually centered even when the CSS-anchor feature flag is enabled.
Changes:
- Added
cssAnchorPositioningSettings?: {disable?: boolean}toAnchoredOverlayto allow opting out of native CSS anchor positioning. - Updated
SelectPanelto disable native CSS anchor positioning forvariant="modal". - Added a changeset for an
@primer/reactminor release.
Show a summary per file
| File | Description |
|---|---|
| packages/react/src/SelectPanel/SelectPanel.tsx | Passes cssAnchorPositioningSettings.disable for modal variant to preserve manual centering. |
| packages/react/src/AnchoredOverlay/AnchoredOverlay.tsx | Adds new prop and gates native CSS anchor positioning behavior on disable. |
| .changeset/select-panel-modal-css-anchor-positioning.md | Declares a minor bump and summarizes the new prop + SelectPanel behavior change. |
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 4
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Integration test results from github/github-ui PR: |
Overview
Adds a
cssAnchorPositioningSettingsprop toAnchoredOverlaywith adisableoption that opts an individual overlay out of native CSS anchor positioning. We use this forSelectPanel, specifically to disable CSS anchor positioning for themodalvariant so it stays manually centered.There may be cases where CSS anchored positioning is not wanted, so this allows users to disable that behavior. This would remain even when we deprecate (and remove) JS-based anchored positioning.
Changelog
New
cssAnchorPositioningSettings?: {disable?: boolean}prop toAnchoredOverlay. Settingdisable: trueopts the overlay out of native CSS anchor positioning even when theprimer_react_css_anchor_positioningfeature flag is enabled and the browser supports it.Changed
SelectPanelnow passescssAnchorPositioningSettings={{disable: variant === 'modal'}}so themodalvariant remains manually centered instead of being repositioned by CSS anchor positioning.Rollout strategy
The new prop is additive and optional, and the
SelectPanelchange is scoped to themodalvariant, so this is backwards compatible. Matches the changeset (@primer/reactminor).Testing & Reviewing
primer_react_css_anchor_positioningfeature flag in a browser that supports native CSS anchor positioning (e.g. recent Chrome).SelectPanelwithvariant="modal"and confirm it stays centered on screen instead of being repositioned next to its trigger.SelectPanelusages and otherAnchoredOverlayconsumers still position correctly — they don't setdisable, so behavior is unchanged.Merge checklist