-
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
Event listener attached to document
will still be called after calling event.stopPropagation()
#12518
Comments
If you need to forbid it from reaching the document, you could put a ref on the Hope this helps! |
Thanks for your reply. I know that By the way, will this issue get resolved if #2043 gets addressed? |
@vincentbel this is because React's own listener is registered on the document as well, not on the element where the event originated from. Here's an example that explains what's happening. |
We're changing this in React 17 by attaching events to the root. |
If you want to try it, we released 17 RC yesterday with this change: |
Do you want to request a feature or report a bug?
A bug.
What is the current behavior?
Event listener attached to
document
will still be called after callingevent.stopPropagation()
on target.Example: (codesandbox link)
console will log:
What is the expected behavior?
handleClickOnDocument
won't be called and no log in console.Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
The text was updated successfully, but these errors were encountered: