-
Notifications
You must be signed in to change notification settings - Fork 628
chore: add portal context #6815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: f31ce63 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
👋 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! |
@copilot add tests to ensure elements render correctly inside custom Portal when PortalContext is supplied and on the default otherwise |
@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. |
size-limit report 📦
|
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: francinelucca <[email protected]>
@copilot add a storybook story that demonstrates how to use PortalContext to render items within a different Portal than the default |
@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. |
…#6821) Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: francinelucca <[email protected]> Co-authored-by: Marie Lucca <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this 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.
👋 Hi from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/2184 |
@copilot fix failing test |
@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. |
🔴 ci completed with status |
@@ -43,6 +43,10 @@ function ensureDefaultPortal() { | |||
} | |||
} | |||
|
|||
export const PortalContext = React.createContext<{ |
There was a problem hiding this comment.
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?
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<{ |
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 corePortal
component, its exports, new Storybook examples, and additional tests to ensure correct behavior when usingPortalContext
and container overrides.Changelog
New
PortalContext
toPortal.tsx
, allowing consumers to specify aportalContainerName
via React context, which determines the portal root container for content rendering. ThePortal
component now prioritizes the context value unless overridden by its owncontainerName
prop.Portal.test.tsx
to verify correct portal rendering behavior when usingPortalContext
, including context-only, default fallback, undefined context, and prop override scenarios.WithPortalContext
) inPortal.features.stories.tsx
to demonstrate how to usePortalContext
for controlling portal rendering, including context and prop override cases.Changed
index.ts
and the package entry point to includePortalContext
, making it available for consumers.Removed
Rollout strategy
Testing & Reviewing
Merge checklist