Skip to content

Commit 822b841

Browse files
authored
fix: Fix crash on defaultItems in S2 Combobox (#8259)
1 parent a6f868a commit 822b841

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

packages/@react-spectrum/s2/src/ComboBox.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ const ComboboxInner = forwardRef(function ComboboxInner(props: ComboBoxProps<any
433433
description: descriptionMessage,
434434
errorMessage,
435435
children,
436+
defaultItems,
436437
items,
437438
size = 'M',
438439
labelPosition = 'top',
@@ -555,10 +556,10 @@ const ComboboxInner = forwardRef(function ComboboxInner(props: ComboBoxProps<any
555556
</UNSTABLE_ListBoxLoadingSentinel>
556557
);
557558

558-
if (typeof children === 'function' && items) {
559+
if (typeof children === 'function') {
559560
renderer = (
560561
<>
561-
<Collection items={items}>
562+
<Collection items={items ?? defaultItems}>
562563
{children}
563564
</Collection>
564565
{listBoxLoadingCircle}

packages/@react-spectrum/s2/stories/ComboBox.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export const Dynamic: Story = {
9595
),
9696
args: {
9797
label: 'Favorite ice cream flavor',
98-
items
98+
defaultItems: items
9999
}
100100
};
101101

@@ -106,7 +106,7 @@ function VirtualizedCombobox(props) {
106106
}
107107

108108
return (
109-
<ComboBox {...props} items={items}>
109+
<ComboBox {...props} defaultItems={items}>
110110
{(item) => <ComboBoxItem id={(item as IExampleItem).id} textValue={(item as IExampleItem).label}>{(item as IExampleItem).label}</ComboBoxItem>}
111111
</ComboBox>
112112
);

0 commit comments

Comments
 (0)