feat(ThemeProvider): add contextOnly prop to prevent rendering of wrapping div#7898
Conversation
🦋 Changeset detectedLatest commit: 43b2c1c 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 |
|
There was a problem hiding this comment.
Pull request overview
Adds a contextOnly option to @primer/react’s ThemeProvider so consumers can opt out of the extra wrapping <div> (while still receiving theme context), aligning migration ergonomics from @primer/styled-react.
Changes:
- Added
contextOnly?: booleantoThemeProviderPropsand updatedThemeProviderrendering behavior when enabled. - Added unit tests asserting wrapper
<div>presence/absence and that theme context remains available whencontextOnlyis set. - Updated
package-lock.jsonentries to reflect@primer/reactversion38.25.0as referenced by workspace/example package manifests.
Show a summary per file
| File | Description |
|---|---|
| packages/styled-react/src/components/ThemeProvider.tsx | Adds a no-op contextOnly prop for API compatibility with @primer/react. |
| packages/react/src/ThemeProvider.tsx | Implements contextOnly behavior by skipping the wrapper <div> and only rendering the context provider. |
| packages/react/src/tests/ThemeProvider.test.tsx | Adds test coverage for the new contextOnly behavior. |
| package-lock.json | Updates lockfile to reflect @primer/react version 38.25.0 references. |
Copilot's findings
- Files reviewed: 3/4 changed files
- Comments generated: 1
|
👋 Hi from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/21854 |
Relates to https://github.com/github/primer/issues/6568
Seeing some issues in dotcom as a result of rendering the ThemeProvider div when switching from @primer/styled-react (no div) to @primer/react ThemeProvider. Adding opt-out mechanism via
contextOnlyprop.Changelog
New
contextOnlyprop toThemeProviderPropsand updated the implementation so that whencontextOnlyis true, the provider only supplies theme context without rendering a wrapping<div>withdata-*attributes.contextOnlybehavior, verifying both the absence of the wrapper<div>and that theme context is still provided to descendants.contextOnlyprop toThemeProviderPropsfor API compatibility with@primer/react, as documented in the prop's comment.Rollout strategy
Testing & Reviewing
Merge checklist