Skip to content

Commit aa83c12

Browse files
acr92reidbarber
andauthored
[Typescript] Combobox: Fix onSelectionChange type declaration (#5852)
onSelectionChange can be invoked with a null key if the user clears the input. packages/@react-stately/combobox/src/useComboBoxState.ts line 225-229 Co-authored-by: Reid Barber <reid@reidbarber.com>
1 parent f1cd495 commit aa83c12

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@ export interface ComboBoxValidationValue {
4141
inputValue: string
4242
}
4343

44-
export interface ComboBoxProps<T> extends CollectionBase<T>, Omit<SingleSelection, 'disallowEmptySelection'>, InputBase, TextInputBase, Validation<ComboBoxValidationValue>, FocusableProps<HTMLInputElement>, LabelableProps, HelpTextProps {
44+
export interface ComboBoxProps<T> extends CollectionBase<T>, Omit<SingleSelection, 'disallowEmptySelection' | 'onSelectionChange'>, InputBase, TextInputBase, Validation<ComboBoxValidationValue>, FocusableProps<HTMLInputElement>, LabelableProps, HelpTextProps {
4545
/** The list of ComboBox items (uncontrolled). */
4646
defaultItems?: Iterable<T>,
4747
/** The list of ComboBox items (controlled). */
4848
items?: Iterable<T>,
4949
/** Method that is called when the open state of the menu changes. Returns the new open state and the action that caused the opening of the menu. */
5050
onOpenChange?: (isOpen: boolean, menuTrigger?: MenuTriggerAction) => void,
51+
/** Handler that is called when the selection changes. */
52+
onSelectionChange?: (key: Key | null) => any,
5153
/** The value of the ComboBox input (controlled). */
5254
inputValue?: string,
5355
/** The default value of the ComboBox input (uncontrolled). */

0 commit comments

Comments
 (0)