Skip to content

Commit 2474041

Browse files
andrewchoughAndrew Choughreidbarber
authored
Replace otherProps with section.props to ensure that section props are properly passed in (#4845)
Co-authored-by: Andrew Chough <[email protected]> Co-authored-by: Reid Barber <[email protected]>
1 parent 9f15402 commit 2474041

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ interface ListBoxSectionProps<T> extends StyleProps {
265265
section: Node<T>
266266
}
267267

268-
function ListBoxSection<T>({section, className, style, ...otherProps}: ListBoxSectionProps<T>) {
268+
function ListBoxSection<T>({section, className, style}: ListBoxSectionProps<T>) {
269269
let {state} = useContext(InternalListBoxContext)!;
270270
let [headingRef, heading] = useSlot();
271271
let {headingProps, groupProps} = useListBoxSection({
@@ -298,7 +298,7 @@ function ListBoxSection<T>({section, className, style, ...otherProps}: ListBoxSe
298298

299299
return (
300300
<section
301-
{...filterDOMProps(otherProps)}
301+
{...filterDOMProps(section.props)}
302302
{...groupProps}
303303
className={className || section.props?.className || 'react-aria-Section'}
304304
style={style || section.props?.style}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,13 @@ describe('ListBox', () => {
131131
it('should support sections', () => {
132132
let {getAllByRole} = render(
133133
<ListBox aria-label="Sandwich contents" selectionMode="multiple">
134-
<Section>
134+
<Section data-test-prop="test-section-1">
135135
<Header>Veggies</Header>
136136
<Item id="lettuce">Lettuce</Item>
137137
<Item id="tomato">Tomato</Item>
138138
<Item id="onion">Onion</Item>
139139
</Section>
140-
<Section>
140+
<Section data-test-prop="test-section-2">
141141
<Header>Protein</Header>
142142
<Item id="ham">Ham</Item>
143143
<Item id="tuna">Tuna</Item>
@@ -154,6 +154,9 @@ describe('ListBox', () => {
154154

155155
expect(groups[0]).toHaveAttribute('aria-labelledby');
156156
expect(document.getElementById(groups[0].getAttribute('aria-labelledby'))).toHaveTextContent('Veggies');
157+
158+
expect(groups[0]).toHaveAttribute('data-test-prop', 'test-section-1');
159+
expect(groups[1]).toHaveAttribute('data-test-prop', 'test-section-2');
157160
});
158161

159162
it('should support dynamic collections', () => {

0 commit comments

Comments
 (0)