-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Bug: "Clear" button unmounts on click faster than other components, causing popover issue #4171
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
Comments
Thanks for the detailed report @getaaron, we'll look in this soon. |
It is not so much a bug as something like a race condition. It does not not render outside of the correct DOM hierarchy. |
Ok, that seems plausible. So why does this happen reliably 100% of the time for the clear button, and never for the other clicks? What's different? |
I think this may be related to #532 |
Greetings @getaaron , I come bearing a 1 line solution and learned a bit more about the event object as this should allow you to compare the DOM hierarchy at the time of mouseDown instead of at the time of the useEffect callback. e.composedPath().includes(popRef.current) For more information about This all said, the core functionality of react-select does not seem to be operating in a way that I would consider a "bug". Perhaps it is different than other clickable items for various reasons and perhaps there may be performance improvements to be gained, but the underlying cause of the issues seems to be more related to the useEffect callback method in the example you provided. I appreciate your feedback and investigation into the root cause. This appears to resolve your use case so I will mark this as closed, but I can re-open this if necessary. |
This is a bug report against the latest version of react-select 3.1.0, when placed inside a react-bootstrap Popover.
Code sandbox here: https://codesandbox.io/s/react-select-v3-popover-clear-issue-98lvm?file=/example.js
Reproduction steps:
Expected Behavior
The elements clear and the popover stays open.
Actual Behavior
The elements clear and the popover closes.
Notes
This effect allows the user to close the popover by clicking outside of it:
In the case of all other clicks (like clicking an option, or the react-select dropdown arrow), this works fine.
In the case of the clear button,
e.target
is set to some DOM element that is not contained withinpopRef
.I think this is a bug in react-select because I believe all clicks should be handled the same way.
In addition to a fix, I'd love any suggestions of a temporary workaround.
The text was updated successfully, but these errors were encountered: