data-component adr part 3#7819
Conversation
🦋 Changeset detectedLatest commit: 0c0214b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 stable data-component attributes (per ADR rollout) to several Primer React components and introduces unit tests to verify those attributes are rendered.
Changes:
- Add
data-componentmarkers toDetails,Flash,FormControl(and related slots),Header, andHeading. - Extend internal
InputValidationto accept/pass through adata-componentvalue forFormControl.Validation. - Add/extend unit tests asserting
data-componentattributes for the updated components.
Show a summary per file
| File | Description |
|---|---|
| packages/react/src/internal/components/InputValidation.tsx | Adds optional data-component prop and applies it to the rendered Text. |
| packages/react/src/Heading/Heading.tsx | Adds data-component="Heading" to the root element. |
| packages/react/src/Heading/tests/Heading.test.tsx | Adds a test asserting Heading renders the data-component attribute. |
| packages/react/src/Header/Header.tsx | Adds data-component to Header, Header.Item, and Header.Link. |
| packages/react/src/Header/Header.test.tsx | Adds tests asserting data-component attributes for Header and subcomponents. |
| packages/react/src/FormControl/FormControlLeadingVisual.tsx | Adds data-component="FormControl.LeadingVisual". |
| packages/react/src/FormControl/FormControlLabel.tsx | Adds data-component="FormControl.Label" to the label render. |
| packages/react/src/FormControl/FormControlCaption.tsx | Adds data-component="FormControl.Caption". |
| packages/react/src/FormControl/FormControl.tsx | Adds data-component="FormControl" to the layout wrapper elements. |
| packages/react/src/FormControl/_FormControlValidation.tsx | Passes data-component="FormControl.Validation" into InputValidation. |
| packages/react/src/FormControl/tests/FormControl.test.tsx | Adds tests for FormControl/slot data-component attributes (one test currently has a lint-breaking unused variable). |
| packages/react/src/Flash/Flash.tsx | Adds data-component="Flash" to the root element. |
| packages/react/src/Flash/tests/Flash.test.tsx | Adds a test asserting Flash renders the data-component attribute. |
| packages/react/src/Details/Details.tsx | Adds data-component to Details root and Details.Summary. |
| packages/react/src/Details/tests/Details.test.tsx | Adds tests asserting Details and Details.Summary render data-component attributes. |
Copilot's findings
- Files reviewed: 16/16 changed files
- Comments generated: 1
| expect(container.firstElementChild).toHaveAttribute('data-component', 'FormControl') | ||
| expect(getByText(LABEL_TEXT)).toHaveAttribute('data-component', 'FormControl.Label') | ||
|
|
||
| const leadingVisual = container.querySelector('[data-component="FormControl.LeadingVisual"]') |
|
🤖 Lint issues have been automatically fixed and committed to this PR. |
Relates to https://github.com/github/primer/issues/6497
Changelog
New
Add data-component attributes and associated tests for Details, Flash, FormControl (+ update InputValidation to forward from FormControl.Validation), Header, and Heading.
Rollout strategy
Testing & Reviewing
Merge checklist