🐛(react) fix closing of menu via toggle button
Previously it was not possible to close the menu when clicking on the toggle button on search select. It was caused by a conflicting state update. 1. Downshift triggers closing the menu from getToggleButtonProps 2. wrapperProps was calling downshiftReturn.openMenu()
This commit is contained in:
@@ -136,7 +136,11 @@ export const SelectMultiSearchable = forwardRef<SelectHandle, SubProps>(
|
||||
wrapperProps: {
|
||||
onClick: () => {
|
||||
inputRef.current?.focus();
|
||||
downshiftReturn.openMenu();
|
||||
// This is important because if we don't check that: when clicking on the toggle button
|
||||
// when the menu is open, it will close and reopen immediately.
|
||||
if (!downshiftReturn.isOpen) {
|
||||
downshiftReturn.openMenu();
|
||||
}
|
||||
},
|
||||
},
|
||||
toggleButtonProps: downshiftReturn.getToggleButtonProps(),
|
||||
|
||||
Reference in New Issue
Block a user