data-component adr part 5#7867
Conversation
🦋 Changeset detectedLatest commit: 06c2480 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 data-component attributes to additional @primer/react components to support the ongoing “data-component” ADR work, along with targeted unit tests and a changeset for a minor release.
Changes:
- Add
data-componentattributes for NavList (root + SubNav), Autocomplete (Input + Overlay), AnchoredOverlay (responsive close button container), and ActionMenu (Button + Overlay + attempted Anchor tagging). - Add/extend unit tests to assert the new attributes are present under expected render conditions.
- Add a changeset for
@primer/reactminor release.
Show a summary per file
| File | Description |
|---|---|
| packages/react/src/NavList/NavList.tsx | Adds data-component attributes to NavList root and NavList.SubNav. |
| packages/react/src/NavList/NavList.test.tsx | Adds a test asserting NavList/SubNav are tagged. |
| packages/react/src/Autocomplete/AutocompleteOverlay.tsx | Tags the rendered overlay with data-component="Autocomplete.Overlay". |
| packages/react/src/Autocomplete/AutocompleteInput.tsx | Tags the input with data-component="Autocomplete.Input". |
| packages/react/src/Autocomplete/Autocomplete.test.tsx | Adds a test asserting overlay is tagged when menu is shown. |
| packages/react/src/AnchoredOverlay/AnchoredOverlay.tsx | Tags the responsive close button container. |
| packages/react/src/AnchoredOverlay/AnchoredOverlay.test.tsx | Adds a test asserting the close button container is tagged. |
| packages/react/src/ActionMenu/ActionMenu.tsx | Tags ActionMenu.Button and ActionMenu.Overlay; adds conditional tagging logic for ActionMenu.Anchor. |
| packages/react/src/ActionMenu/ActionMenu.test.tsx | Adds a test asserting ActionMenu parts are tagged after opening. |
| .changeset/quick-ants-lead.md | Records a minor-release changeset for the new attributes/tests. |
Copilot's findings
- Files reviewed: 10/10 changed files
- Comments generated: 3
|
👋 Hi from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/21767 |
| <div | ||
| ref={containerRef} | ||
| className={styles.ActionMenuContainer} | ||
| data-component="ActionMenu.Overlay" |
There was a problem hiding this comment.
I kind of feel like this should be on the AnchoredOverlay instead (override)
| {React.cloneElement(child, { | ||
| ...anchorProps, | ||
| ref: anchorRef, | ||
| className: clsx(anchorProps.className, child.props.className), | ||
| onClick: onButtonClick, | ||
| onKeyDown: onButtonKeyDown, | ||
| })} |
There was a problem hiding this comment.
I think this should be data-component="ActionMenu.Anchor"
| <div className={classes.ResponsiveCloseButtonContainer}> | ||
| <div | ||
| className={classes.ResponsiveCloseButtonContainer} | ||
| data-component="AnchoredOverlay.CloseButtonContainer" |
There was a problem hiding this comment.
I'd rename to data-component="AnchoredOverlay.CloseButton" and put it on the IconButton instead
| renderAnchor({ | ||
| ref: anchorRef, | ||
| id: anchorId, | ||
| 'aria-haspopup': 'true', | ||
| 'aria-expanded': open, | ||
| tabIndex: 0, | ||
| onClick: onAnchorClick, | ||
| onKeyDown: onAnchorKeyDown, | ||
| ...(shouldRenderAsPopover ? {popoverTarget: popoverId} : {}), |
There was a problem hiding this comment.
I'd add data-component="AnchoredOverlay.Anchor"
| <Overlay | ||
| returnFocusRef={anchorRef} |
There was a problem hiding this comment.
data-component="AnchoredOverlay"
| expect(container.querySelector('[data-component="Autocomplete.Overlay"]')).toBeInTheDocument() | ||
| }) |
There was a problem hiding this comment.
missing: Autocomplete.Input, Autocomplete.Menu
| describe('NavList', () => { | ||
| implementsClassName(NavList) | ||
|
|
||
| it('renders data-component attributes for NavList and NavList.SubNav', () => { |
There was a problem hiding this comment.
missing: data-component tests for NavItems
Relates to https://github.com/github/primer/issues/6497
Changelog
New
Add data-component attributes and associated tests for ActionMenu, AnchoredOverlay, Autocomplete, and NavList
Rollout strategy
Testing & Reviewing
Merge checklist