downshift ๐ŸŽ v6.0.0 Release Notes

Release Date: 2020-07-21 // 10 months ago
  • 6.0.0 (2020-07-21)

    ๐Ÿ’ฅ BREAKING CHANGES

    • โšก๏ธ Update TS typings for selectedItem to accept null in both useSelect and useCombobox.

    โšก๏ธ 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 accept null for the item parameter, in useSelect and useCombobox + in Downshift where this was missing. useMultipleSelection type for itemToString stays the same as it can't receive null as item.

    โšก๏ธ 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 - the type 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 + typeonIsOpenChange?: (changes: UseComboboxStateChange\<Item\>) =\> voidonHighlightedIndexChange?: (changes: UseComboboxStateChange\<Item\>) =\> voidonStateChange?: (changes: UseComboboxStateChange\<Item\>) =\> voidonInputValueChange?: (changes: UseComboboxStateChange\<Item\>) =\> void
    

    where

    export interface UseComboboxStateChangeOptions\<Item\>extends UseComboboxDispatchAction\<Item\> { // type and optional parameters needed to compute the next statechanges: Partial\<UseComboboxState\<Item\>\> // partial state changes proposed by the hook}export interface UseComboboxDispatchAction\<Item\> {type: UseComboboxStateChangeTypesshiftKey?: booleangetItemNodeFromIndex?: (index: number) =\> HTMLElementinputValue?: stringindex?: numberhighlightedIndex?: numberselectedItem?: Item | nullselectItem?: 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