🐛(react) fix failing selection of last removed item
Previsouly when selecting item A and then removing it, it was impossible to select it again. This was caused by the internal memory of useSelect that only provides undefined selectedItem inside the onStateChange callback when the item has not changed. So by forcing it everytime to null it is now providing it everytime.
This commit is contained in:
@@ -32,6 +32,7 @@ export const SelectMultiSimple = (props: SubProps) => {
|
||||
const downshiftReturn = useSelect({
|
||||
items: options,
|
||||
itemToString: optionToString,
|
||||
selectedItem: null, // Important, without this we are not able to re-select the last removed option.
|
||||
defaultHighlightedIndex: 0, // after selection, highlight the first item.
|
||||
stateReducer: (state, actionAndChanges) => {
|
||||
const { changes, type } = actionAndChanges;
|
||||
|
||||
Reference in New Issue
Block a user