-
Notifications
You must be signed in to change notification settings - Fork 48.3k
MouseEvent doesn't recognize react's Synthetic onMouseLeave #12978
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
@DannyvanHolten It works see https://jsfiddle.net/pLdrau59/9/ and https://jsfiddle.net/yv6qdchL/11/ I think what you mean here is a child can't fire a parent event? But if a event can fire everywhere, you don't need react You can use this instead https://reactjs.org/docs/portals.html#event-bubbling-through-portals |
This is not a solution. You just inverted the click and the mouseleave. So on leave it will simulate an onclick, on Click it still doesn't simulate a mouseLeave |
@DannyvanHolten Yes, that is indeed a bug I am looking into it now |
Hey @DannyvanHolten! This is due to the way React shims correct Since a browser will fire function simulateMouseMove(from, to) {
if (from) {
from.dispatchEvent(
new MouseEvent('mouseout', {
bubbles: true,
cancelable: true,
relatedTarget: to,
}),
);
}
if (to) {
to.dispatchEvent(
new MouseEvent('mouseover', {
bubbles: true,
cancelable: true,
relatedTarget: from,
}),
);
} |
Sorry, closed it on accident. |
Doesn't feel like there's an action item here. React is intentionally using different events internally to provide a more solid polyfill. |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
The Javascript MouseEvent doesn't recognize react's synthetic event.
Code example:
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:
This doesn't work: https://jsfiddle.net/Luktwrdm/456/
Whereas this does: https://jsfiddle.net/7xyyyjc5/1/
Click the button and it doesn't trigger the onMouseLeave event.
What is the expected behavior?
That the MouseEvent sees the synthetic event and handles the onMouseLeave correctly.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React version 16.2 - all browsers.
Not that I know of.
The text was updated successfully, but these errors were encountered: