Skip to content

Commit 8d4f407

Browse files
authored
Fix Menu Section aria-label (#6423)
* Fix Menu Section aria-label
1 parent c57671e commit 8d4f407

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ function MenuSection<T>({section, className, style, parentMenuRef, ...otherProps
229229
let [headingRef, heading] = useSlot();
230230
let {headingProps, groupProps} = useMenuSection({
231231
heading,
232-
'aria-label': section['aria-label'] ?? undefined
232+
'aria-label': section.props['aria-label'] ?? undefined
233233
});
234234

235235
let children = useCachedChildren({

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ export const MenuExample = () => (
2525
<Button aria-label="Menu"></Button>
2626
<Popover>
2727
<Menu className={styles.menu} onAction={action('onAction')}>
28-
<Section className={styles.group}>
29-
<Header style={{fontSize: '1.2em'}}>Section 1</Header>
28+
<Section className={styles.group} aria-label={'Section 1'}>
3029
<MyMenuItem>Foo</MyMenuItem>
3130
<MyMenuItem>Bar</MyMenuItem>
3231
<MyMenuItem>Baz</MyMenuItem>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,15 @@ describe('Menu', () => {
116116
let itemRef = React.createRef();
117117
render(
118118
<Menu aria-label="Test" ref={listBoxRef}>
119-
<Section ref={sectionRef}>
119+
<Section ref={sectionRef} aria-label="Felines">
120120
<MenuItem ref={itemRef}>Cat</MenuItem>
121121
</Section>
122122
</Menu>
123123
);
124124
expect(listBoxRef.current).toBeInstanceOf(HTMLElement);
125125
expect(sectionRef.current).toBeInstanceOf(HTMLElement);
126126
expect(itemRef.current).toBeInstanceOf(HTMLElement);
127+
expect(sectionRef.current).toHaveAttribute('aria-label', 'Felines');
127128
});
128129

129130
it('should support hover', async () => {

0 commit comments

Comments
 (0)