Skip to content

Commit 0f832b6

Browse files
Ensure Menu component has the data-rac data attribute (#6436)
Co-authored-by: Reid Barber <[email protected]>
1 parent 379e8d6 commit 0f832b6

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

packages/react-aria-components/src/Menu.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,16 +189,22 @@ function MenuInner<T extends object>({props, collection, menuRef: ref}: MenuInne
189189
}
190190
}, [leftOffset, popoverContainer]);
191191

192+
let renderProps = useRenderProps({
193+
defaultClassName: 'react-aria-Menu',
194+
className: props.className,
195+
style: props.style,
196+
values: {}
197+
});
198+
192199
return (
193200
<FocusScope>
194201
<div
195202
{...filterDOMProps(props)}
196203
{...menuProps}
204+
{...renderProps}
197205
ref={ref}
198206
slot={props.slot || undefined}
199-
onScroll={props.onScroll}
200-
style={props.style}
201-
className={props.className ?? 'react-aria-Menu'}>
207+
onScroll={props.onScroll}>
202208
<Provider
203209
values={[
204210
[MenuStateContext, state],

packages/react-aria-components/test/Menu.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ describe('Menu', () => {
6060
act(() => {jest.runAllTimers();});
6161
});
6262

63+
it('should have the base set of aria and data attributes', () => {
64+
let {getByRole, getAllByRole} = renderMenu();
65+
let menu = getByRole('menu');
66+
expect(menu).toHaveAttribute('data-rac');
67+
68+
for (let menuitem of getAllByRole('menuitem')) {
69+
expect(menuitem).toHaveAttribute('data-rac');
70+
}
71+
});
72+
6373
it('should render with default classes', () => {
6474
let {getByRole, getAllByRole} = renderMenu();
6575
let menu = getByRole('menu');

0 commit comments

Comments
 (0)