Skip to content

data component adr part 8 - #8112

Merged
llastflowers merged 14 commits into
mainfrom
llastflowers/6497/data-component-ADR-part-8
Jul 7, 2026
Merged

data component adr part 8#8112
llastflowers merged 14 commits into
mainfrom
llastflowers/6497/data-component-ADR-part-8

Conversation

@llastflowers

Copy link
Copy Markdown
Contributor

Relates to https://github.com/github/primer/issues/6497

Changelog

New

Add data-component attributes and associated tests for:

SplitPageLayout
Stack
StateLabel
SubNav
TabNav
Text
TextArea
ThemeProvider

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

Merge checklist

@llastflowers
llastflowers requested a review from a team as a code ownerJuly 2, 2026 21:43
@changeset-bot

changeset-botBot commented Jul 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2f068ed

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
NameType
@primer/reactMinor

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

@github-actionsgithub-actionsBot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Jul 2, 2026
@github-actions

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. If this doesn't work, you can also use the original workflow here. 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.

CopilotAI 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

This PR continues the “data-component” ADR rollout by adding data-component attributes to several Primer React components and adding/adjusting unit tests (and snapshots) to assert those attributes are present, including composition cases like SplitPageLayout built on PageLayout.

Changes:

  • Add data-component attributes to ThemeProvider, Text, Textarea, Stack/Stack.Item, StateLabel, SubNav (and subcomponents), and TabNav (and subcomponents).
  • Add/update unit tests and snapshots to verify the new data-component attributes.
  • Extend PageLayout (and slot components) to accept a data-component prop so composed wrappers (e.g. SplitPageLayout) can stamp their own identifiers.
Show a summary per file
FileDescription
packages/react/src/ThemeProvider.tsxAdds data-component="ThemeProvider" to the ThemeProvider wrapper element.
packages/react/src/tests/ThemeProvider.test.tsxAdds an assertion that ThemeProvider renders data-component.
packages/react/src/Textarea/Textarea.tsxAdds data-component="Textarea" to the <textarea>.
packages/react/src/Textarea/Textarea.test.tsxAdds a test verifying Textarea’s data-component attribute.
packages/react/src/Text/Text.tsxAdds data-component="Text" to the Text root element.
packages/react/src/Text/Text.test.tsxAdds a test verifying Text’s data-component attribute.
packages/react/src/TabNav/TabNav.tsxAdds data-component attributes to TabNav and TabNav.Link.
packages/react/src/TabNav/tests/TabNav.test.tsxAdds a test verifying TabNav and TabNav.Linkdata-component attributes.
packages/react/src/SubNav/SubNav.tsxAdds data-component attributes to SubNav, SubNav.Links, and SubNav.Link.
packages/react/src/SubNav/SubNav.test.tsxAdds a test verifying SubNav and subcomponents data-component attributes.
packages/react/src/tests/snapshots/SubNavLink.test.tsx.snapUpdates snapshots to include data-component="SubNav.Link".
packages/react/src/StateLabel/StateLabel.tsxAdds data-component="StateLabel" to the StateLabel root element.
packages/react/src/StateLabel/tests/StateLabel.test.tsxAdds a test verifying StateLabel’s data-component attribute and adjusts formatting.
packages/react/src/StateLabel/tests/snapshots/StateLabel.test.tsx.snapUpdates snapshots to include data-component="StateLabel".
packages/react/src/Stack/Stack.tsxAdds data-component to Stack and StackItem.
packages/react/src/Stack/tests/Stack.test.tsxAdds a test verifying Stack’s data-component attribute.
packages/react/src/Stack/tests/StackItem.test.tsxAdds a test verifying StackItem’s data-component attribute.
packages/react/src/SplitPageLayout/SplitPageLayout.tsxAdds data-component stamping for SplitPageLayout and slot wrappers; copies slot markers to integrate with PageLayout’s slot system.
packages/react/src/SplitPageLayout/SplitPageLayout.test.tsxAdds a test verifying data-component for SplitPageLayout and all subcomponents.
packages/react/src/PageLayout/PageLayout.tsxAdds support for overriding data-component via props for PageLayout and slot components (used by composed wrappers like SplitPageLayout).

Review details

Comments suppressed due to low confidence (2)

packages/react/src/Text/Text.tsx:31

  • data-component is set before {...rest}, which means a consumer-provided data-component prop will override it. If the intent is for Primer to own this identifier, move data-component after the spread so it always wins.
 <Component
className={clsx(className, classes.Text)}
data-component="Text"
data-size={size}
data-weight={weight}
data-white-space={whiteSpace}
{...rest}
ref={ref}
/>

packages/react/src/Textarea/Textarea.tsx:150

  • data-component is currently before {...rest}, so callers can override it by passing data-component in props. Move data-component after the spread so the component always controls this attribute.
 <textarea
value={value}
defaultValue={defaultValue}
data-component="Textarea"
data-resize={resize}
aria-required={required}
aria-invalid={isValid === 'error' ? 'true' : 'false'}
ref={ref}
disabled={disabled}
rows={rows}
cols={cols}
className={classes.TextArea}
onChange={handleTextareaChange}
style={{
minHeight,
maxHeight,
...style,
}}
{...rest}
aria-describedby={
  • Files reviewed: 21/21 changed files
  • Comments generated: 6
  • Review effort level: Low

Comment threadpackages/react/src/SubNav/SubNav.tsx
Comment threadpackages/react/src/SubNav/SubNav.tsx
Comment threadpackages/react/src/SubNav/SubNav.tsx
Comment threadpackages/react/src/TabNav/TabNav.tsx
Comment threadpackages/react/src/Stack/Stack.tsx
Comment on lines 58 to 84
export type PageLayoutProps = {
/** The maximum width of the page container */
containerWidth?: 'full' | 'medium' | 'large' | 'xlarge'
/** The spacing between the outer edges of the page container and the viewport */
padding?: keyof typeof SPACING_MAP
rowGap?: keyof typeof SPACING_MAP
columnGap?: keyof typeof SPACING_MAP

/** Private prop to allow SplitPageLayout to customize slot components */
_slotsConfig?: Record<'header' | 'footer' | 'sidebar', React.ElementType>
className?: string
style?: React.CSSProperties
'data-component'?: string
}

// TODO: refs
const Root: React.FC<React.PropsWithChildren<PageLayoutProps>> = ({
containerWidth = 'xlarge',
padding = 'normal',
rowGap = 'normal',
columnGap = 'normal',
children,
className,
style,
_slotsConfig: slotsConfig,
'data-component': dataComponent = 'PageLayout',
}) => {
@github-actions
github-actionsBot requested a deployment to storybook-preview-8112 July 2, 2026 21:48 Abandoned
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actions
github-actionsBot requested a deployment to storybook-preview-8112 July 2, 2026 21:52 Abandoned
@github-actions
github-actionsBottemporarily deployed to storybook-preview-8112 July 2, 2026 22:02 Inactive
@github-actions
github-actionsBottemporarily deployed to storybook-preview-8112 July 2, 2026 22:49 Inactive
@llastflowersllastflowers added the Canary Release Apply this label when you want CI to create a canary release of the current PR label Jul 2, 2026
@github-actions
github-actionsBottemporarily deployed to storybook-preview-8112 July 2, 2026 23:20 Inactive
@llastflowersllastflowers added Canary Release Apply this label when you want CI to create a canary release of the current PR and removed Canary Release Apply this label when you want CI to create a canary release of the current PR labels Jul 3, 2026
@primer-integration

primer-integrationBot commented Jul 6, 2026

Copy link
Copy Markdown

Integration test results from github/github-ui PR:

Passed CI  Passed
Running VRT  Running
Waiting Projects   Waiting

@francineluccafrancinelucca left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment on lines +135 to +139
;(Header as WithSlotMarker<typeof Header>).__SLOT__ = PageLayout.Header.__SLOT__
;(Content as WithSlotMarker<typeof Content>).__SLOT__ = PageLayout.Content.__SLOT__
;(Pane as WithSlotMarker<typeof Pane>).__SLOT__ = PageLayout.Pane.__SLOT__
;(Sidebar as WithSlotMarker<typeof Sidebar>).__SLOT__ = PageLayout.Sidebar.__SLOT__
;(Footer as WithSlotMarker<typeof Footer>).__SLOT__ = PageLayout.Footer.__SLOT__

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

curious why we're adding these in this PR 👀

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

It was part of keeping the PageLayout and SplitPageLayout sub-component identities consistent so that the PageLayout data-component attributes don't override the SplitPageLayout ones.

@llastflowers
llastflowers added this pull request to the merge queueJul 7, 2026
Merged via the queue into main with commit 50face0Jul 7, 2026
62 checks passed
@llastflowers
llastflowers deleted the llastflowers/6497/data-component-ADR-part-8 branch July 7, 2026 16:50
@primerprimerBot mentioned this pull request Jul 7, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Canary ReleaseApply this label when you want CI to create a canary release of the current PRintegration-tests: recommendedThis 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.

4 participants

@llastflowers@jonrohan@francinelucca