Skip to content

Move shared React contexts into dedicated modules#7939

Open
joshblack wants to merge 2 commits into
joshblack/eslint-react-refresh/pluginfrom
joshblack/eslint-react-refresh/fix-contexts
Open

Move shared React contexts into dedicated modules#7939
joshblack wants to merge 2 commits into
joshblack/eslint-react-refresh/pluginfrom
joshblack/eslint-react-refresh/fix-contexts

Conversation

@joshblack

@joshblack joshblack commented Jun 8, 2026

Copy link
Copy Markdown
Member

Closes #

No linked issue.

Moves shared React contexts and Portal registry helpers out of component files so those component modules only export components.

Changelog

New

  • Added dedicated context modules for ActionList groups, Dialog, Portal, RadioGroup, Tooltip, and TooltipV2.
  • Added a Portal registry helper module for registerPortalRoot and default portal root management.

Changed

  • Updated internal imports and Portal stories to use the new context/registry modules.

Removed

  • Removed context and registry exports from component implementation files.

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; internal module organization only, with public exports preserved through existing barrels.

Testing & Reviewing

Review that context values moved to {Name}Context.ts files and Portal registry behavior is unchanged.

Merge checklist

@changeset-bot

changeset-bot Bot commented Jun 8, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 8910bf9

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

@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 Jun 8, 2026
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

⚠️ Action required

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

To publish a canary release for integration testing, apply the Canary Release label to this PR.

@joshblack joshblack changed the title joshblack/eslint react refresh/fix contexts Move shared React contexts into dedicated modules Jun 8, 2026
@joshblack joshblack added skip changeset This change does not need a changelog integration-tests: skipped manually Changes in this PR do not require an integration test labels Jun 8, 2026
@joshblack joshblack marked this pull request as ready for review June 8, 2026 17:36
@joshblack joshblack requested a review from a team as a code owner June 8, 2026 17:36
@joshblack joshblack requested review from Copilot and liuliu-dev June 8, 2026 17:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors @primer/react internals by moving shared React Context objects (and Portal root registry helpers) into dedicated modules, keeping component implementation files focused on exporting components while updating internal consumers accordingly.

Changes:

  • Added dedicated *Context.ts modules for Tooltip/TooltipV2, Dialog, RadioGroup, ActionList Group, and Portal.
  • Extracted Portal root registry/default-root management into Portal/portalRoot.ts and updated Portal + stories to use it.
  • Updated internal imports (e.g., IconButton, ActionMenu, ActionList consumers) to reference the new modules.
Show a summary per file
File Description
packages/react/src/TooltipV2/TooltipContext.ts New module housing TooltipV2 context.
packages/react/src/TooltipV2/Tooltip.tsx Uses extracted TooltipV2 context module instead of defining it inline.
packages/react/src/Tooltip/TooltipContext.ts New module housing Tooltip (v1) context.
packages/react/src/Tooltip/Tooltip.tsx Uses extracted Tooltip (v1) context module instead of defining it inline.
packages/react/src/RadioGroup/RadioGroupContext.ts New module housing RadioGroup context.
packages/react/src/RadioGroup/RadioGroup.tsx Imports RadioGroup context from dedicated module.
packages/react/src/RadioGroup/index.ts Re-exports RadioGroupContext from the new context module.
packages/react/src/Radio/Radio.tsx Updates RadioGroupContext import to new module path.
packages/react/src/Portal/portalRoot.ts New module for portal root registry + default portal root creation/registration.
packages/react/src/Portal/PortalContext.ts New module housing Portal context.
packages/react/src/Portal/Portal.tsx Uses extracted PortalContext + portal root helpers.
packages/react/src/Portal/Portal.features.stories.tsx Updates story imports to use new PortalContext/portalRoot modules.
packages/react/src/Portal/index.ts Preserves exports while sourcing PortalContext/registerPortalRoot from new modules.
packages/react/src/Dialog/DialogContext.ts New module housing Dialog context.
packages/react/src/Dialog/Dialog.tsx Imports DialogContext from dedicated module instead of exporting inline.
packages/react/src/Button/IconButton.tsx Updates Tooltip/TooltipV2 context imports to new context modules.
packages/react/src/ActionMenu/ActionMenu.tsx Updates DialogContext import to new module path.
packages/react/src/ActionList/Selection.tsx Updates GroupContext import to new module path.
packages/react/src/ActionList/Item.tsx Updates GroupContext import to new module path; updates TooltipV2 context import.
packages/react/src/ActionList/index.ts Rewires GroupContext to come from new module and exposes it on ActionList.
packages/react/src/ActionList/GroupContext.ts New module housing ActionList GroupContext.
packages/react/src/ActionList/Group.tsx Imports GroupContext from dedicated module instead of defining/exporting inline.

Copilot's findings

  • Files reviewed: 22/22 changed files
  • Comments generated: 0

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 integration-tests: skipped manually Changes in this PR do not require an integration test skip changeset This change does not need a changelog staff Author is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants