Skip to content

Commit 1193073

Browse files
authored
Fix Aria label on sections (#5603)
1 parent 125d65c commit 1193073

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

Diff for: packages/react-aria-components/src/ListBox.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ function ListBoxSection<T>({section, className, style}: ListBoxSectionProps<T>)
282282
let [headingRef, heading] = useSlot();
283283
let {headingProps, groupProps} = useListBoxSection({
284284
heading,
285-
'aria-label': section['aria-label'] ?? undefined
285+
'aria-label': section.props['aria-label'] ?? undefined
286286
});
287287

288288
let children = useCachedChildren({

Diff for: packages/react-aria-components/stories/index.stories.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ export const ListBoxSections = () => (
7272
<MyListBoxItem>Baz</MyListBoxItem>
7373
</Section>
7474
<Separator style={{borderTop: '1px solid gray', margin: '2px 5px'}} />
75-
<Section className={styles.group}>
76-
<Header style={{fontSize: '1.2em'}}>Section 1</Header>
75+
<Section className={styles.group} aria-label="Section 2">
7776
<MyListBoxItem>Foo</MyListBoxItem>
7877
<MyListBoxItem>Bar</MyListBoxItem>
7978
<MyListBoxItem>Baz</MyListBoxItem>

Diff for: packages/react-aria-components/test/ListBox.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ describe('ListBox', () => {
140140
<ListBoxItem id="tomato">Tomato</ListBoxItem>
141141
<ListBoxItem id="onion">Onion</ListBoxItem>
142142
</Section>
143-
<Section data-test-prop="test-section-2">
144-
<Header>Protein</Header>
143+
<Section data-test-prop="test-section-2" aria-label="Protein">
145144
<ListBoxItem id="ham">Ham</ListBoxItem>
146145
<ListBoxItem id="tuna">Tuna</ListBoxItem>
147146
<ListBoxItem id="tofu">Tofu</ListBoxItem>
@@ -157,6 +156,7 @@ describe('ListBox', () => {
157156

158157
expect(groups[0]).toHaveAttribute('aria-labelledby');
159158
expect(document.getElementById(groups[0].getAttribute('aria-labelledby'))).toHaveTextContent('Veggies');
159+
expect(groups[1].getAttribute('aria-label')).toEqual('Protein');
160160

161161
expect(groups[0]).toHaveAttribute('data-test-prop', 'test-section-1');
162162
expect(groups[1]).toHaveAttribute('data-test-prop', 'test-section-2');

0 commit comments

Comments
 (0)