fix: correct Object.assign usage in ActionMenu, DataTable exports in @primer/styled-react#7738
Conversation
🦋 Changeset detectedLatest commit: a74369d 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 from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/18174 |
There was a problem hiding this comment.
Pull request overview
Prevents @primer/styled-react from mutating imported @primer/react components via Object.assign by introducing wrapper “root” components, and adds a __SLOT__ marker to @primer/react’s DataTable Table export to support slot-based APIs.
Changes:
- Replace
Object.assign(PrimerComponent, …)withObject.assign(WrapperRoot, …)forActionMenuandDataTable/Tablein@primer/styled-react. - Preserve/copy
__SLOT__markers on the styled-react wrappers to keep slot matching working. - Add
Table.__SLOT__to@primer/reactDataTable exports and add a changeset.
Show a summary per file
| File | Description |
|---|---|
| packages/styled-react/src/components/DataTable.tsx | Introduces TableRoot wrapper and assigns static members onto it instead of mutating the imported experimental Table. |
| packages/styled-react/src/components/ActionMenu.tsx | Introduces ActionMenuRoot wrapper and assigns static members onto it instead of mutating the imported ActionMenu. |
| packages/react/src/DataTable/index.ts | Adds SlotMarker typing and assigns a __SLOT__ symbol to Table. |
| .changeset/datatable-slot-marker.md | Adds a changeset entry describing the mutation fix release. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 2
…geset Agent-Logs-Url: https://github.com/primer/react/sessions/7eebd40d-859e-492c-b9e3-7e91102d8a90 Co-authored-by: francinelucca <40550942+francinelucca@users.noreply.github.com>
|
@primer/styled-reactwas mutating imported@primer/reactcomponents viaObject.assign, causing unintended side effects. This PR introduces wrapper components to prevent mutation, preserves__SLOT__markers for slot-based APIs, and addsTable.__SLOT__to@primer/react's DataTable export.Changelog
New
@primer/reactDataTableTablenow has a__SLOT__marker (Table.__SLOT__ = Symbol('Table')) for slot-based API compatibilityChanged
@primer/styled-reactActionMenuandTable: replaced directObject.assignonto imported@primer/reactcomponents with wrapper components (ActionMenuRoot,TableRoot) — originals are no longer mutatedTableRootimplemented viaReact.forwardRef<HTMLTableElement, TableProps>to correctly forward refs to the underlyingPrimerDataTable__SLOT__symbols are copied onto the wrapper components so slot matching continues to workRemoved
Rollout strategy
Testing & Reviewing
Both packages type-check and lint cleanly. The
forwardRefwrapper matches the signature of the originalPrimerDataTable(React.forwardRef<HTMLTableElement, TableProps>), so existing ref usage is unaffected.Merge checklist