Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/@react-stately/select/src/useSelectState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ export function useSelectState<T extends object, M extends SelectionMode = 'sing
focusStrategy,
open(focusStrategy: FocusStrategy | null = null) {
// Don't open if the collection is empty.
if (listState.collection.size !== 0) {
if (listState.collection.size !== 0 || props.allowsEmptyCollection) {
setFocusStrategy(focusStrategy);
triggerState.open();
}
},
toggle(focusStrategy: FocusStrategy | null = null) {
if (listState.collection.size !== 0) {
if (listState.collection.size !== 0 || props.allowsEmptyCollection) {
setFocusStrategy(focusStrategy);
triggerState.toggle();
}
Expand Down
4 changes: 3 additions & 1 deletion packages/@react-types/select/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ export interface SelectProps<T, M extends SelectionMode = 'single'> extends Coll
/** Sets the default open state of the menu. */
defaultOpen?: boolean,
/** Method that is called when the open state of the menu changes. */
onOpenChange?: (isOpen: boolean) => void
onOpenChange?: (isOpen: boolean) => void,
/** Whether the select should be allowed to be open when the collection is empty. */
allowsEmptyCollection?: boolean
}

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