-
Notifications
You must be signed in to change notification settings - Fork 561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Combobox] Controlled component doesn't close popover on select #483
Comments
Thank you for opening this issue |
Fixed in 0.8.5 |
I'm facing the same problem while using a controlled input component in @reach/combobox 0.15.0 |
Hi, this is still happening in ^0.16 repro: https://codesandbox.io/s/sweet-galileo-kzkpb?file=/src/index.js |
Same here, I just got this when upgrading a minor it wasn't there in 0.16.1 |
I'd recommend downgrading for the moment, I'm still working on this one as time allows. Sorry about that! The latest update fixed another bug but seems to have caused a regression here, so I need to make sure they are both resolved before I release the next patch. |
I'm seeing this behaviour from v0.16.0 onwards. |
🐛 Bug report
Current Behavior
When a value is selected on a controlled Combobox the
onSelect
callback fires but the popover does not closeExpected behavior
The popover should close when an item is selected
Reproducible example
https://codesandbox.io/s/musing-thunder-rmzvv
Suggested solution(s)
It seems this was introduced in d3836a6 when the callbacks went from being fired before an action was sent to the reducer to them being called inside the reducer. This means that the combobox context
value
updates before the controlledvalue
which triggers a state where the combobox receives a change in controlledvalue
and reopens the popover immediately after closing it.I think the best solution would be in a controlled component to never update the combobox context's internal
value
except in the controlled component specifichandleValueChange
inComboboxInput
. This would require setting some sort of "controlled" flag in the combobox state but would prevent future race conditions like this.Additional context
Your environment
The text was updated successfully, but these errors were encountered: