Skip to content

AnchoredOverlay: Allow customization of CSS anchor positioning - #7888

Merged
TylerJDev merged 13 commits into
mainfrom
tylerjdev/allow-customize-css-anchor-positioning
Jun 10, 2026
Merged

AnchoredOverlay: Allow customization of CSS anchor positioning#7888
TylerJDev merged 13 commits into
mainfrom
tylerjdev/allow-customize-css-anchor-positioning

Conversation

@TylerJDev

@TylerJDevTylerJDev commented May 27, 2026

Copy link
Copy Markdown
Member

Adds cssAnchorPositioningSettings prop to AnchoredOverlay so consumers can control how the overlay behaves when native CSS anchor positioning is active.

When CSS anchor positioning is active, the overlay relies on the stylesheet defined position-try-fallbacks list on .AnchoredOverlay, which can flip the overlay to sides the consumer may not want. This prop lets consumers opt into other fallback behavior via a fallbackStrategy:

  • "default" - use the built-in CSS fallback rules (current behavior).
  • "none" - keep the requested side with no CSS fallbacks (position-try-fallbacks: none).
  • "opposite-side" - only allow flipping to the opposite side along the relevant axis (flip-block for outside-top/outside-bottom, flip-inline for outside-left/outside-right).

The setting is applied as an inline position-try-fallbacks style on the overlay element while it is open, and ignored entirely when CSS anchor positioning is not active.

Changelog

New

  • cssAnchorPositioningSettings?: { fallbackStrategy: 'default' | 'none' | 'opposite-side' } prop on AnchoredOverlay.

Changed

  • When the overlay opens with CSS anchor positioning active, it now writes/removes the inline position-try-fallbacks property based on cssAnchorPositioningSettings. Existing callers that don't pass the prop default to "default", preserving current behavior.
  • Adds default behavior for inside-* sides. CSS anchor positioning doesn't natively support them, so this ensures that CSS anchor positioning does not break when used.

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

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Added/updated previews (Storybook)
  • Changes are SSR compatible
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge
  • (GitHub staff only) Integration tests pass at github/github-ui

@changeset-bot

changeset-botBot commented May 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 66ae2f5

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

This PR includes changesets to release 1 package
NameType
@primer/reactMinor

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

@github-actionsgithub-actionsBot 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 May 27, 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-actionsBot requested a deployment to storybook-preview-7888 May 27, 2026 20:38 Abandoned
@TylerJDevTylerJDev added the Canary Release Apply this label when you want CI to create a canary release of the current PR label Jun 9, 2026
@github-actions
github-actionsBottemporarily deployed to storybook-preview-7888 June 9, 2026 23:37 Inactive
@primer

primerBot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

🤖 Formatting issues have been automatically fixed and committed to this PR.

@TylerJDev
TylerJDev marked this pull request as ready for review June 10, 2026 12:20
@TylerJDev
TylerJDev requested a review from a team as a code ownerJune 10, 2026 12:20
@github-actions
github-actionsBottemporarily deployed to storybook-preview-7888 June 10, 2026 12:23 Inactive

CopilotAI 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.

Pull request overview

Adds a new consumer-facing prop on AnchoredOverlay to control native CSS anchor positioning fallback behavior by writing position-try-fallbacks inline when CSS anchor positioning is active.

Changes:

  • Adds cssAnchorPositioningSettings prop and applies/removes inline position-try-fallbacks while the overlay is open (CSS anchor positioning path only).
  • Extends CSS anchor-positioning selectors to handle inside-*data-side values.
  • Adds unit tests for the new fallback strategies and updates Storybook stories + adds a changeset.
Show a summary per file
FileDescription
packages/react/src/AnchoredOverlay/AnchoredOverlay.tsxAdds the new prop, writes/removes inline position-try-fallbacks, and introduces helper to compute fallback values.
packages/react/src/AnchoredOverlay/AnchoredOverlay.test.tsxAdds tests asserting the inline position-try-fallbacks behavior for none / opposite-side and that it’s ignored when CSS anchor positioning is disabled.
packages/react/src/AnchoredOverlay/AnchoredOverlay.module.cssExtends CSS anchor positioning rules so inside-* sides don’t break when CSS anchor positioning is active.
packages/react/src/AnchoredOverlay/AnchoredOverlay.features.stories.tsxUpdates a features story to pass cssAnchorPositioningSettings.
packages/react/src/AnchoredOverlay/AnchoredOverlay.dev.stories.tsxAdds dev stories/demos for the new fallback strategies (grid scenarios).
.changeset/anchored-overlay-css-anchor-positioning-settings.mdDeclares a minor bump for the new public prop.

Copilot's findings

  • Files reviewed: 6/6 changed files
  • Comments generated: 2

Comment threadpackages/react/src/AnchoredOverlay/AnchoredOverlay.tsx Outdated
Comment threadpackages/react/src/AnchoredOverlay/AnchoredOverlay.tsx
@github-actions
github-actionsBottemporarily deployed to storybook-preview-7888 June 10, 2026 12:34 Inactive
TylerJDevand others added 3 commits June 10, 2026 08:54
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

CopilotAI 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.

Copilot's findings

  • Files reviewed: 6/6 changed files
  • Comments generated: 2

Comment threadpackages/react/src/AnchoredOverlay/AnchoredOverlay.tsx Outdated
Comment thread.changeset/anchored-overlay-css-anchor-positioning-settings.md Outdated
@github-actions
github-actionsBot requested a deployment to storybook-preview-7888 June 10, 2026 13:07 Abandoned
@primer

primerBot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

🤖 Lint issues have been automatically fixed and committed to this PR.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment threadpackages/react/src/AnchoredOverlay/AnchoredOverlay.tsx Outdated
@github-actions
github-actionsBot requested a deployment to storybook-preview-7888 June 10, 2026 19:35 Abandoned
@github-actions
github-actionsBottemporarily deployed to storybook-preview-7888 June 10, 2026 19:45 Inactive

@liuliu-devliuliu-dev 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.

:shipit:

@primer-integration

primer-integrationBot commented Jun 10, 2026

Copy link
Copy Markdown

Integration test results from github/github-ui PR:

Passed CI  Passed
Waiting VRT   Waiting
Running Projects  Running

@TylerJDev
TylerJDev added this pull request to the merge queueJun 10, 2026
Merged via the queue into main with commit 45be31bJun 10, 2026
54 checks passed
@TylerJDev
TylerJDev deleted the tylerjdev/allow-customize-css-anchor-positioning branch June 10, 2026 20:51
@primerprimerBot mentioned this pull request Jun 10, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Canary ReleaseApply this label when you want CI to create a canary release of the current PRintegration-tests: recommendedThis change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpmstaffAuthor is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@TylerJDev@liuliu-dev