data-component adr part 6#7889
Conversation
🦋 Changeset detectedLatest commit: 40063a9 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 |
|
Add data-component attributes and associated tests for PageHeader, PageLayout, Pagehead, Popover, Portal, and ProgressBar
There was a problem hiding this comment.
Pull request overview
Part 6 of the data-component ADR work: adds data-component attributes to PageHeader, PageLayout, Pagehead, Popover, Portal, and ProgressBar (plus subcomponents), with accompanying tests. Also normalizes PageHeader subcomponent data-component values from PH_* / bare TitleArea to the dotted PageHeader.* convention.
Changes:
- Adds
data-componentto root + subcomponent elements across six components and their tests. - Renames PageHeader subcomponent
data-componentvalues (PH_*,TitleArea) toPageHeader.*and updates the:has()selectors inPageHeader.module.cssthat referencedTitleArea. - Adds a minor changeset.
Show a summary per file
| File | Description |
|---|---|
| packages/react/src/ProgressBar/ProgressBar.tsx | Adds data-component to ProgressBar root and Item. |
| packages/react/src/ProgressBar/ProgressBar.test.tsx | Tests for new data-component attributes. |
| packages/react/src/Portal/Portal.tsx | Sets data-component on the imperatively created portal div. |
| packages/react/src/Portal/Portal.test.tsx | Adds assertions for the portal data-component across cases. |
| packages/react/src/Popover/Popover.tsx | Adds data-component to Popover and Popover.Content. |
| packages/react/src/Popover/Popover.test.tsx | Tests for Popover data-component attributes. |
| packages/react/src/PageLayout/PageLayout.tsx | Adds data-component to Root, Header, Content, Pane, Sidebar, Footer. |
| packages/react/src/PageLayout/PageLayout.test.tsx | Tests for PageLayout data-component attributes. |
| packages/react/src/PageLayout/snapshots/PageLayout.test.tsx.snap | Updated snapshots reflecting new attributes. |
| packages/react/src/PageHeader/PageHeader.tsx | Adds/renames data-component across all PageHeader subcomponents to PageHeader.*. |
| packages/react/src/PageHeader/PageHeader.test.tsx | Tests for PageHeader data-component attributes. |
| packages/react/src/PageHeader/PageHeader.module.css | Updates :has([data-component='TitleArea']) selectors to use PageHeader.TitleArea (but leaves PH_* selectors). |
| packages/react/src/Pagehead/Pagehead.tsx | Adds data-component to Pagehead. |
| packages/react/src/Pagehead/Pagehead.test.tsx | Test for Pagehead data-component. |
| .changeset/pretty-coats-sell.md | Minor changeset describing the feature. |
Copilot's findings
- Files reviewed: 15/15 changed files
- Comments generated: 1
| aria-labelledby={BaseComponent === 'nav' ? ariaLabelledBy : undefined} | ||
| className={clsx(classes.Navigation, className)} | ||
| data-component="PH_Navigation" | ||
| data-component="PageHeader.Navigation" |
joshblack
left a comment
There was a problem hiding this comment.
Just wanted to leave a comment real quick, some of the data-component values that exist already might have usage (specifically thinking of the PH_* ones so just wanted to double-check on the release plan for those before approving 👀
| const Actions = ({children, className, hidden = false}: ActionsProps) => { | ||
| return ( | ||
| <div className={clsx(classes.Actions, className)} data-component="PH_Actions" {...getHiddenDataAttributes(hidden)}> | ||
| <div |
There was a problem hiding this comment.
I think some of these may be used (like PH_Actions) based on: https://github.com/search?q=repo%3Agithub%2Fgithub-ui+PH_&type=code so we might need to be more careful for them
There was a problem hiding this comment.
Yeah, I was thinking about this and was planning to check the dotcom usages as well! I think we should definitely update the attribute names in primer/react to keep things consistent, so we need to update them in dotcom too. Since there are only 3 files that reference the old attributes, this seems like an easy enough migration effort.
I suppose we would just need to make sure that we have a migration PR in the same github-ui deployment group as the primer/react version upgrade that involves this PR, since the changes need to happen in both places at the same time to avoid breaking anything 🤔 Coordinating with RC on this (possibly asking them to queue both PRs to make sure they're deployed together) seems like the way to do it safely. What do you think? 👀
There was a problem hiding this comment.
Totally agreed, makes sense to me 👍
There was a problem hiding this comment.
jk, @francinelucca correctly pointed out that this needs to be part of a major update. I'll revert everything related to the PH_ stuff in this PR and separate it out!
Relates to https://github.com/github/primer/issues/6497
Changelog
New
Add data-component attributes and associated tests for PageHeader, PageLayout, Pagehead, Popover, Portal, and ProgressBar
Rollout strategy
Testing & Reviewing
Merge checklist