-
Notifications
You must be signed in to change notification settings - Fork 220
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
Fix rootClose on unmounting components #117
Conversation
Most likely React unmounted the target in response to some other click.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine. checking for detached nodes is part for the course for this sort of logic in my experience
par* why can't I edit anything |
The alternative is to go back to the old approach, which ought to be safe to this kind of thing. wdyt? I think the "replace popover" scenario is rare enough that we don't have to rush out another release. |
Actually, I don't think this works. Imagine the user clicks on a router link and navigates... this logic would still make the page transition. Is there a way to attach our document listener to fire before the React click handler? |
@jquense You know DOM stuff a lot better than me... this is a reasonable fix? |
capture seems fine...the thought is that if we fire before react, then there isn't any chance of the target being nonexistent due to an unmount caused by the event? I think its reasonable, I guess technically you could break it by using |
What the heck is onClickCapture? What even is capture supposed to be other than an escape hatch for priority? |
there aren't a ton of use cases for the capture flag, but generally its used for event delegation, e.g. you can mimic The react event system will let you listen for the events with |
I don't understand what any of that means. But, yeah, in practice this seems to mean that we fire before the target could potentially get unmounted by a normal React |
🌈 |
Most likely React unmounted the target in response to some other click.
@jquense This logic is not ideal but probably fine in practice? What do you think?