Skip to content

Commit f40b575

Browse files
vovsemenvLFDanLuyihuiliao
authored
fix (#8984)
Co-authored-by: Daniel Lu <[email protected]> Co-authored-by: Yihui Liao <[email protected]>
1 parent 33b6092 commit f40b575

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/@react-stately/select/src/useSelectState.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,13 @@ export function useSelectState<T extends object, M extends SelectionMode = 'sing
162162
focusStrategy,
163163
open(focusStrategy: FocusStrategy | null = null) {
164164
// Don't open if the collection is empty.
165-
if (listState.collection.size !== 0) {
165+
if (listState.collection.size !== 0 || props.allowsEmptyCollection) {
166166
setFocusStrategy(focusStrategy);
167167
triggerState.open();
168168
}
169169
},
170170
toggle(focusStrategy: FocusStrategy | null = null) {
171-
if (listState.collection.size !== 0) {
171+
if (listState.collection.size !== 0 || props.allowsEmptyCollection) {
172172
setFocusStrategy(focusStrategy);
173173
triggerState.toggle();
174174
}

packages/@react-types/select/src/index.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ export interface SelectProps<T, M extends SelectionMode = 'single'> extends Coll
6161
/** Sets the default open state of the menu. */
6262
defaultOpen?: boolean,
6363
/** Method that is called when the open state of the menu changes. */
64-
onOpenChange?: (isOpen: boolean) => void
64+
onOpenChange?: (isOpen: boolean) => void,
65+
/** Whether the select should be allowed to be open when the collection is empty. */
66+
allowsEmptyCollection?: boolean
6567
}
6668

6769
export interface AriaSelectProps<T, M extends SelectionMode = 'single'> extends SelectProps<T, M>, DOMProps, AriaLabelingProps, FocusableDOMProps {

0 commit comments

Comments
 (0)