Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 12, 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.
  • Fixed accessibility issues in the WithPortalContext Storybook story by replacing hardcoded background and border colors with proper Primer design tokens, ensuring the story adapts correctly to both light and dark themes with excellent color contrast.

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

Accessibility Fix

The Portal context story previously used hardcoded colors (#f0f8ff, #e6f3ff, etc.) that didn't adapt to dark theme, causing accessibility issues. This has been resolved by:

  • Replacing all inline styles with CSS classes using semantic design tokens
  • Using var(--bgColor-accent-muted), var(--bgColor-attention-emphasis), etc. for backgrounds
  • Applying var(--borderColor-*-emphasis) for borders
  • Adding var(--fgColor-onEmphasis) for proper text contrast on emphasis backgrounds

Screenshots:

  • Light Theme: Light theme with proper theming
  • Dark Theme: Dark theme with proper theming

Merge checklist


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI mentioned this pull request Sep 12, 2025
13 tasks
Copy link

changeset-bot bot commented Sep 12, 2025

⚠️ No Changeset found

Latest commit: 93dcd00

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Copilot Copilot AI requested a review from francinelucca September 12, 2025 17:49
Copilot finished work on behalf of francinelucca September 12, 2025 17:49
Copy link
Contributor

👋 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!

@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 Sep 12, 2025
@github-actions github-actions bot requested a deployment to storybook-preview-6847 September 12, 2025 17:58 Abandoned
Copy link
Contributor

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 88.61 KB (0%)
packages/react/dist/browser.umd.js 88.66 KB (0%)

1 similar comment
Copy link
Contributor

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 88.61 KB (0%)
packages/react/dist/browser.umd.js 88.66 KB (0%)

@francinelucca francinelucca merged commit 4ad5155 into chore/add-portal-context Sep 12, 2025
49 of 79 checks passed
@francinelucca francinelucca deleted the copilot/stack-pr-6815-2 branch September 12, 2025 18:23
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants