[WIP] fix: address accessibility issue with dark theme using token background colors #6847
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.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
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:var(--bgColor-accent-muted)
,var(--bgColor-attention-emphasis)
, etc. for backgroundsvar(--borderColor-*-emphasis)
for bordersvar(--fgColor-onEmphasis)
for proper text contrast on emphasis backgroundsScreenshots:
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.