Skip to content

chore: always render ActionMenu in viewport when inside Dialog under feature flag#7524

Merged
francinelucca merged 19 commits intomainfrom
chore/action-menu-display-in-viewport-enhancement
Mar 3, 2026
Merged

chore: always render ActionMenu in viewport when inside Dialog under feature flag#7524
francinelucca merged 19 commits intomainfrom
chore/action-menu-display-in-viewport-enhancement

Conversation

@francinelucca
Copy link
Member

@francinelucca francinelucca commented Feb 11, 2026

Relates to https://github.com/github/primer/issues/6361

Implements @TylerDixon's suggestion to have the ActionMenu.Overlay be able to detect if its being rendered inside a Dialog (via a (new) DialogContext) to then apply displayInViewport=true. Adding this under a feature flag since its somewhat of a widespread change.

Changelog

New

  • add DialogContext to Dialog
  • Added the primer_react_action_menu_display_in_viewport_inside_dialog feature flag to DefaultFeatureFlags, enabling control over overlay display behavior inside dialogs.
  • Updated ActionMenu.Overlay to use the new feature flag and detect if it is inside a Dialog, modifying the displayInViewport prop logic accordingly.

Changed

  • Wrapped the ActionMenu InsideDialog story in FeatureFlags and removed the explicit displayInViewport prop from ActionMenu.Overlay, relying on the feature flag for behavior.

Removed

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

@francinelucca francinelucca requested a review from a team as a code owner February 11, 2026 02:01
@changeset-bot
Copy link

changeset-bot bot commented Feb 11, 2026

🦋 Changeset detected

Latest commit: 31e8b99

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

@github-actions github-actions bot added the staff Author is a staff member label Feb 11, 2026
@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Feb 11, 2026
@github-actions
Copy link
Contributor

👋 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. Or, apply the integration-tests: skipped manually label to skip these checks.

Copy link
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

Adds a feature-flagged behavior change so ActionMenu.Overlay can automatically opt into displayInViewport when rendered inside a portal (e.g., inside a Dialog), aiming to improve overlay positioning/clipping in portaled contexts.

Changes:

  • Adds a new default feature flag: primer_react_action_menu_display_in_viewport_inside_portal.
  • Updates ActionMenu.Overlay to consult the feature flag and detect whether it is inside a portal to adjust displayInViewport.
  • Updates the InsideDialog ActionMenu story to enable the flag and remove the explicit displayInViewport prop.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
packages/react/src/Portal/Portal.tsx Attempts to ensure a “default” PortalContext exists so descendants can detect portal rendering.
packages/react/src/FeatureFlags/DefaultFeatureFlags.ts Registers the new feature flag with a default value of false.
packages/react/src/ActionMenu/ActionMenu.tsx Adds feature-flag logic and portal detection to influence displayInViewport.
packages/react/src/ActionMenu/ActionMenu.examples.stories.tsx Enables the feature flag in the InsideDialog story and relies on the new default behavior.

@github-actions github-actions bot requested a deployment to storybook-preview-7524 February 11, 2026 02:08 Abandoned
@francinelucca francinelucca marked this pull request as draft February 11, 2026 02:11
Copy link
Contributor

Copilot AI commented Feb 11, 2026

@francinelucca I've opened a new pull request, #7525, to work on those changes. Once the pull request is ready, I'll request review from you.

Updated the version of '@primer/react' from patch to minor and modified the ActionMenu rendering behavior.
…e_portal feature flag (#7525)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: francinelucca <40550942+francinelucca@users.noreply.github.com>
Copy link
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.

Left one clarifying question, everything else looks great! Approving in advance!

variant={variant}
displayInViewport={displayInViewport}
displayInViewport={
displayInViewport !== undefined ? displayInViewport : featureFlagDisplayInViewportInsidePortal && isInsideDialog
Copy link
Member

Choose a reason for hiding this comment

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

Interesting that we have this in props and automatically applied from context. Should we remove it from props or do we want to preserve displayInViewport=false as an override?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was wanting to let the gate open for someone to want to do displayInViewport=true ad-hoc. (like if your ActionMenu is not inside a Dialog, but you still want to force it to displayInViewPort. A good use-case I see for this would be the "close as" - completed, duplicate - not planned - menu for issues when inside the sidebar - it works well now due to some marie-fu, but this'd be a much cleaner solution - ).
And then I got to thinking that if we allow displayInViewport=true, then we should probably allow displayInViewport=false to override the default behavior, hence this seemingly weird conditional. Thoughts?

Copy link
Contributor

Copilot AI commented Feb 18, 2026

@francinelucca I've opened a new pull request, #7565, to work on those changes. Once the pull request is ready, I'll request review from you.

…rtal (#7565)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: francinelucca <40550942+francinelucca@users.noreply.github.com>
@primer-integration
Copy link

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

@primer-integration
Copy link

Integration test results from github/github-ui:

Passed  CI   Passed
Passed  VRT   Passed
Passed  Projects   Passed

All checks passed!

@francinelucca francinelucca added this pull request to the merge queue Mar 3, 2026
Merged via the queue into main with commit f7bdd1c Mar 3, 2026
52 checks passed
@francinelucca francinelucca deleted the chore/action-menu-display-in-viewport-enhancement branch March 3, 2026 14:43
@primer primer bot mentioned this pull request Mar 3, 2026
llastflowers pushed a commit that referenced this pull request Mar 3, 2026
…feature flag (#7524)

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

6 participants