From fff3f9d10436c8e5d89bebf1959c59b2f11ea89b Mon Sep 17 00:00:00 2001 From: llastflowers Date: Thu, 21 May 2026 16:52:57 -0700 Subject: [PATCH 1/9] update ActionMenu and add test --- packages/react/src/ActionMenu/ActionMenu.test.tsx | 13 +++++++++++++ packages/react/src/ActionMenu/ActionMenu.tsx | 7 ++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/react/src/ActionMenu/ActionMenu.test.tsx b/packages/react/src/ActionMenu/ActionMenu.test.tsx index 09303b7923b..27a07601392 100644 --- a/packages/react/src/ActionMenu/ActionMenu.test.tsx +++ b/packages/react/src/ActionMenu/ActionMenu.test.tsx @@ -180,6 +180,19 @@ function ExampleWithSubmenus(): JSX.Element { describe('ActionMenu', () => { implementsClassName(ActionMenu.Button) + it('renders data-component attributes for ActionMenu parts', async () => { + const component = HTMLRender() + const user = userEvent.setup() + + const trigger = component.getByRole('button', {name: 'Toggle Menu'}) + expect(trigger).toHaveAttribute('data-component', 'ActionMenu.Button') + + await user.click(trigger) + + expect(component.baseElement.querySelector('[data-component="AnchoredOverlay"]')).not.toBeNull() + expect(component.baseElement.querySelector('[data-component="ActionMenu.Overlay"]')).not.toBeNull() + }) + it('should open Menu on MenuButton click', async () => { const component = HTMLRender() const button = component.getByRole('button') diff --git a/packages/react/src/ActionMenu/ActionMenu.tsx b/packages/react/src/ActionMenu/ActionMenu.tsx index c0dfb464f39..5291b8d158b 100644 --- a/packages/react/src/ActionMenu/ActionMenu.tsx +++ b/packages/react/src/ActionMenu/ActionMenu.tsx @@ -237,6 +237,9 @@ const Anchor: WithSlotMarker< [isSubmenu, onOpen, parentActionListContext], ) + // only add data-component to the anchor if it's not a button, so we don't accidentally override + const isCustomAnchor = child.type !== Button + return ( {React.cloneElement(child, { @@ -245,6 +248,7 @@ const Anchor: WithSlotMarker< className: clsx(anchorProps.className, child.props.className), onClick: onButtonClick, onKeyDown: onButtonKeyDown, + ...(isCustomAnchor ? {'data-component': 'ActionMenu.Anchor'} : {}), })} ) @@ -256,7 +260,7 @@ export type ActionMenuButtonProps = ButtonProps const MenuButton = React.forwardRef(({...props}, anchorRef) => { return ( - } + variant={{regular: 'anchored', narrow: 'fullscreen'}} + > +
content
+ + + , + ) + + expect(baseElement.querySelector('[data-component="AnchoredOverlay.CloseButtonContainer"]')).toBeInTheDocument() + }) + it('should call onOpen when the anchor is clicked', async () => { const mockOpenCallback = vi.fn() const mockCloseCallback = vi.fn() diff --git a/packages/react/src/AnchoredOverlay/AnchoredOverlay.tsx b/packages/react/src/AnchoredOverlay/AnchoredOverlay.tsx index e0050775587..42cb6ae2926 100644 --- a/packages/react/src/AnchoredOverlay/AnchoredOverlay.tsx +++ b/packages/react/src/AnchoredOverlay/AnchoredOverlay.tsx @@ -395,7 +395,10 @@ export const AnchoredOverlay: React.FC {showXIcon ? ( -
+
Date: Thu, 21 May 2026 17:09:40 -0700 Subject: [PATCH 3/9] update Autocomplete sub-components and add test --- .../react/src/Autocomplete/Autocomplete.test.tsx | 14 ++++++++++++++ .../react/src/Autocomplete/AutocompleteInput.tsx | 1 + .../react/src/Autocomplete/AutocompleteOverlay.tsx | 1 + 3 files changed, 16 insertions(+) diff --git a/packages/react/src/Autocomplete/Autocomplete.test.tsx b/packages/react/src/Autocomplete/Autocomplete.test.tsx index 68e61313b3e..267af66ef32 100644 --- a/packages/react/src/Autocomplete/Autocomplete.test.tsx +++ b/packages/react/src/Autocomplete/Autocomplete.test.tsx @@ -55,6 +55,20 @@ describe('Autocomplete', () => { )) + + it('tags overlay with data-component when menu is shown', async () => { + const user = userEvent.setup() + const {container} = render( + , + ) + const inputNode = container.querySelector('#autocompleteInput')! + await user.type(inputNode, 'z') + + expect(container.querySelector('[data-component="Autocomplete.Overlay"]')).toBeInTheDocument() + }) + it('calls onChange', async () => { const user = userEvent.setup() const onChangeMock = vi.fn() diff --git a/packages/react/src/Autocomplete/AutocompleteInput.tsx b/packages/react/src/Autocomplete/AutocompleteInput.tsx index ef1278451a1..c12898f15f4 100644 --- a/packages/react/src/Autocomplete/AutocompleteInput.tsx +++ b/packages/react/src/Autocomplete/AutocompleteInput.tsx @@ -170,6 +170,7 @@ const AutocompleteInput = React.forwardRef( autoComplete="off" id={id} {...props} + data-component="Autocomplete.Input" /> ) }, diff --git a/packages/react/src/Autocomplete/AutocompleteOverlay.tsx b/packages/react/src/Autocomplete/AutocompleteOverlay.tsx index f0486c5822d..f330153c2ba 100644 --- a/packages/react/src/Autocomplete/AutocompleteOverlay.tsx +++ b/packages/react/src/Autocomplete/AutocompleteOverlay.tsx @@ -78,6 +78,7 @@ function AutocompleteOverlay({ left={position?.left} className={clsx(classes.Overlay, className)} {...overlayProps} + data-component="Autocomplete.Overlay" > {children} From 55b406e8c862c81cee64b7a7183c47717fc3531d Mon Sep 17 00:00:00 2001 From: llastflowers Date: Thu, 21 May 2026 17:17:06 -0700 Subject: [PATCH 4/9] update NavList and add tests --- packages/react/src/NavList/NavList.test.tsx | 20 ++++++++++++++++++++ packages/react/src/NavList/NavList.tsx | 10 ++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/packages/react/src/NavList/NavList.test.tsx b/packages/react/src/NavList/NavList.test.tsx index 05f92549307..684fdf42f29 100644 --- a/packages/react/src/NavList/NavList.test.tsx +++ b/packages/react/src/NavList/NavList.test.tsx @@ -23,6 +23,26 @@ const NextJSLikeLink = React.forwardRef( describe('NavList', () => { implementsClassName(NavList) + it('renders data-component attributes for NavList and NavList.SubNav', () => { + const {container} = render( + + Item 1 + + Item 2 + + Sub Item 1 + + + , + ) + + const nav = container.querySelector('nav') + expect(nav).toHaveAttribute('data-component', 'NavList') + + const subNav = container.querySelector('[data-component="NavList.SubNav"]') + expect(subNav).toBeInTheDocument() + }) + it('supports TrailingAction', async () => { const {getByRole} = render( diff --git a/packages/react/src/NavList/NavList.tsx b/packages/react/src/NavList/NavList.tsx index c81795db695..15e5c3f70c1 100644 --- a/packages/react/src/NavList/NavList.tsx +++ b/packages/react/src/NavList/NavList.tsx @@ -29,7 +29,7 @@ export type NavListProps = { const Root = React.forwardRef(({children, ...props}, ref) => { return ( -