-
Notifications
You must be signed in to change notification settings - Fork 47k
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
onMouseLeave
can be unreliable in Chrome
#4492
Comments
Didn't you write React? |
Best guess: the top-level onMouseOut doesn't fire on the removed node (which is basically what you said, sorry). |
I see the bug in Safari as well, version 8.0.7. In Firefox it happens too, but not so often. |
FYI this happens without React as well. https://jsfiddle.net/ahf3tay5/ |
Well that's just lovely. Time to file a Chrome bug? |
@spicyj It's in IE too, perhaps this is actually a weird spec thing? |
@syranide I have tried with pure JS and it works fine (tested in Mac Chrome) http://jsfiddle.net/2gmzzzv1/1/ |
@pswai You're testing a different scenario, my fiddle shows that this is not a problem with the React event system, it's a "problem" with browser behavior when the hovered nodes are replaced/removed. |
@syranide Ah you are right. Thanks for pointing that out. |
There seems to be bug reports about this for Chrome https://code.google.com/p/chromium/issues/detail?id=276329 |
I'm also having troubles with this event, tested on Chrome, Firefox (stable) and Edge. It only worked fine on Firefox nightly. It fires the onMouseEnter just fine, but it almost never works for the onMouseLeave event. There is no way at all to use this Synthetic Event. |
@henlz Perhaps it's time to file a new issue with a reproducing example? This one is pretty stale, and it's hard to say if they're even related or not. |
@gaearon You're right. I will create one with all the details and steps to reproduce it for a better discussion. |
I’ll close this one as it’s unlikely we’ll make meaningful progress on an issue from 2015. |
@henlz Is there an issue you created for this somewhere? Just ran into this as well :/ |
Is there a workaround for this? |
I investigated this issue and it seems that Chrome and Edge not firing mouseleave on removed DOM nodes is correct according to the UI Events spec:
I filed bugs on firefox and safari for this incorrect behavior. |
Also just ran into this issue. Still investigating workarounds. Anyone find a workaround? Will post back if I find a good way to fix. |
I managed to "fix" this. I'm doing two things:
Seems to work fine now, the event is fired properly. I do not know why though. |
@DamianDobrev Thank you! What an odd problem. I have a button with child SVG's being animated and this was a 4 day headbanger that I finally tracked to here! It was simply a matter of disabling the pointer events on the child svg's. |
I fixed this by invalidating the hover state between renders
|
Does anyone actually understand the root cause of this? |
Thanks a lot, this is very helpful for me |
Summary: Kind of a subtle issue here. If you hover on the Pull button long enough to see the tooltip, then click pull, then wait for the tooltip content to change (add "Pull is currently running.") it will no longer detect onMouseLeave and so the tooltip will not auto-dismiss anymore. This seems to be a quirk of the browser, perhaps related to react synthetic events...? Kind of difficult to attribute exactly, but other people see the same kind of issue: facebook/react#4492 It seems if we add our listener in a layout effect instead of adding it directly via react `onMouseLeave` prop passed ot the div, it keeps the same listener on the DOM node and that means the mouseLeave continues being detected. Reviewed By: quark-zju Differential Revision: D45418402 fbshipit-source-id: a1fe0d063f74f4559a75b68177d4828d0f7d8d80
Thank you. This solution works like a champ |
Helped me! Thanks! |
See this jsfiddle: https://jsfiddle.net/tvxderw3/
In Chrome, as you quickly move your mouse up and down the list, you'll notice that some get stuck in the hover state. This works fine in Safari, and works in Chrome if you use a stable key between the hover states. I think
mouseout
somehow isn't firing if the underlying DOM node is replaced by a new one in the same tick, but it's odd that this is a Chrome-only bug.The text was updated successfully, but these errors were encountered: