Skip to content

Conversation

francinelucca
Copy link
Member

@francinelucca francinelucca commented Sep 9, 2025

This pull request introduces a new PortalContext to the @primer/react library, allowing more flexible and context-driven control over where portal content is rendered. The changes include updates to the core Portal component, its exports, new Storybook examples, and additional tests to ensure correct behavior when using PortalContext and container overrides.

Changelog

New

  • Added PortalContext to Portal.tsx, allowing consumers to specify a portalContainerName via React context, which determines the portal root container for content rendering. The Portal component now prioritizes the context value unless overridden by its own containerName prop.
  • Added new tests in Portal.test.tsx to verify correct portal rendering behavior when using PortalContext, including context-only, default fallback, undefined context, and prop override scenarios.
  • Added a Storybook example (WithPortalContext) in Portal.features.stories.tsx to demonstrate how to use PortalContext for controlling portal rendering, including context and prop override cases.

Changed

  • Updated exports in index.ts and the package entry point to include PortalContext, making it available for consumers.

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

Copy link

changeset-bot bot commented Sep 9, 2025

🦋 Changeset detected

Latest commit: f31ce63

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

This PR includes changesets to release 2 packages
Name Type
@primer/react Minor
@primer/styled-react Major

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 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 Sep 9, 2025
Copy link
Contributor

github-actions bot commented Sep 9, 2025

👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!

@francinelucca
Copy link
Member Author

@copilot add tests to ensure elements render correctly inside custom Portal when PortalContext is supplied and on the default otherwise

Copy link
Contributor

Copilot AI commented Sep 9, 2025

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

Copy link
Contributor

github-actions bot commented Sep 9, 2025

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 88.61 KB (-0.04% 🔽)
packages/react/dist/browser.umd.js 88.66 KB (-0.08% 🔽)

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: francinelucca <[email protected]>
@francinelucca
Copy link
Member Author

@copilot add a storybook story that demonstrates how to use PortalContext to render items within a different Portal than the default

Copy link
Contributor

Copilot AI commented Sep 9, 2025

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

@github-actions github-actions bot requested a deployment to storybook-preview-6815 September 9, 2025 23:29 Abandoned
@francinelucca francinelucca marked this pull request as ready for review September 10, 2025 14:18
@Copilot Copilot AI review requested due to automatic review settings September 10, 2025 14:18
@francinelucca francinelucca requested a review from a team as a code owner September 10, 2025 14:18
@github-actions github-actions bot requested a deployment to storybook-preview-6815 September 10, 2025 14:19 Abandoned
Copilot

This comment was marked as outdated.

Copilot

This comment was marked as outdated.

Copy link
Contributor

@Copilot 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

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

@github-actions github-actions bot requested a deployment to storybook-preview-6815 September 10, 2025 14:23 Abandoned
@primer-integration
Copy link

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

@francinelucca
Copy link
Member Author

@copilot fix failing test

Copy link
Contributor

Copilot AI commented Sep 10, 2025

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

@primer-integration
Copy link

🔴 ci completed with status failure.

@github-actions github-actions bot added integration-tests: failing Changes in this PR cause breaking changes in gh/gh and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Sep 10, 2025
@@ -43,6 +43,10 @@ function ensureDefaultPortal() {
}
}

export const PortalContext = React.createContext<{
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there any docs we can provide as a jsdoc here to give a brief description?

Suggested change
export const PortalContext = React.createContext<{
/**
* Provides the ability for component trees to override the portal root container for a sub-set of the experience.
* The portal will prioritize the context value unless overridden by their own `containerName` prop, and fallback to the default root if neither are specified
*/
export const PortalContext = React.createContext<{

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration-tests: failing Changes in this PR cause breaking changes in gh/gh staff Author is a staff member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants