I just found this function in code and not sure if it can actually work, because it tries to update two state variables sequentially
changeIsOpen
and changeInputValue
are state setters, it looks wrong for me
const toggleOpen = (
event: React.MouseEvent<HTMLButtonElement, MouseEvent>
): void => {
event.preventDefault()
const newOpenState: boolean = !isOpen
changeIsOpen(newOpenState)
const curItem: SelectSuggestV2Item | undefined = items.find(
(item: SelectSuggestV2Item) => item.id === selectedId
)
// If closed and a search was in progress, restore the last selected value
if (!newOpenState && curItem != null && curItem.label !== inputValue) {
changeInputValue(curItem.label)
}
}