6.0.0 (2020-07-21)
BREAKING CHANGES
- Update TS typings for
selectedItem
to acceptnull
in bothuseSelect
anduseCombobox
.
To migrate to the new change, update your types or code if necessary. selectedItem
, defaultSelectedItem
and initialSelectedItem
now have Item | null
instead of Item
type. PR with the changes: #1090
- Update TS typings for
itemToString
to acceptnull
for theitem
parameter, inuseSelect
anduseCombobox
+ inDownshift
where this was missing.useMultipleSelection
type foritemToString
stays the same as it can't receivenull
asitem
.
To migrate to the new change, update your types or code if necessary. itemToString: (item: Item) => string
-> itemToString: (item: Item | null) => string}
. PR with the changes: #1075 #1105
- Pass
type
to the onChange (onInputValueChange, onHighlightedIndexChange, onSelectedItemChange, onIsOpenChange) handler parameters, as specified in the documentation. Also updated the TS typings to reflect this +onStateChange
- thetype
parameter was passed but it was not reflected in the TS types.
To migrate to the new change, update your types or code if necessary, better to view the changes in the PR: #985. Important: please update to the 6.0.2 version since it contains a couple of fixes for the changes in this Breaking Change. Final changes:
stateReducer?: (
state: UseComboboxState<Item>,
actionAndChanges: UseComboboxStateChangeOptions<Item>, // UseComboboxStateChangeOptions has the correct typings
) => Partial<UseComboboxState<Item>> // this now reflects the correct return, which is the partial state.
onSelectedItemChange?: (changes: UseComboboxStateChange<Item>) => void // changes have partial state + type
onIsOpenChange?: (changes: UseComboboxStateChange<Item>) => void
onHighlightedIndexChange?: (changes: UseComboboxStateChange<Item>) => void
onStateChange?: (changes: UseComboboxStateChange<Item>) => void
onInputValueChange?: (changes: UseComboboxStateChange<Item>) => void
where
export interface UseComboboxStateChangeOptions<Item>
extends UseComboboxDispatchAction<Item> { // type and optional parameters needed to compute the next state
changes: Partial<UseComboboxState<Item>> // partial state changes proposed by the hook
}
export interface UseComboboxDispatchAction<Item> {
type: UseComboboxStateChangeTypes
shiftKey?: boolean
getItemNodeFromIndex?: (index: number) => HTMLElement
inputValue?: string
index?: number
highlightedIndex?: number
selectedItem?: Item | null
selectItem?: boolean
}
export interface UseComboboxStateChange<Item>
extends Partial<UseComboboxState<Item>> {
type: UseComboboxStateChangeTypes
}
BREAKING BEHAVIOURS
-
[useCombobox]: When an item is highlighted by keyboard and user closes the menu using mouse/touch, the item is not selected anymore. The only selection on Blur happens using either Tab / Shift+Tab. PR with the changes: #1109
-
[useCombobox & downshift]: When pressing Escape and the menu is open, only close the menu. When the menu is closed and there is an item selected and/or text in the input, clear the selectedItem and the inputValue. PR with the changes: #719