question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

e.stopPropagation() seems to not be working as expect.

See original GitHub issue

I found this issue when I attempted to integrate ReacJs and a jQuery widget.

I bind an click event on input element and document like follow:

var Search = React.createClass({
    handleClick: function(e) {
        e.stopPropagation();
    },
    render: function() {
        return <input onClick={this.handleClick} />
    }
});
document.addEventListener('click', function() {
    console.log('propagation')
}, false);

And everytime I click the input element, chrome devtool logs ‘propagation’ message. Should not document element can not receive click event? I’m confused, Did I miss something?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

22reactions
baurinecommented, Sep 16, 2018

a workaround, use window.addEventListener() to replace document.addEventListener, event.stopPropagation() can stop event propagate to window.

9reactions
gaearoncommented, Aug 10, 2020

We’re fixing this in React 17.

Read more comments on GitHub >

github_iconTop Results From Across the Web

e.stopPropagation() is not working as expected?
live() method handles events once they have propagated to the top of the document, it is not possible to stop propagation of live...
Read more >
The Dangers of Stopping Event Propagation - CSS-Tricks
This bug happens because the Bootstrap code responsible for closing the dropdown menu is listening for click events on the document. But since ......
Read more >
Bubbling and capturing - The Modern JavaScript Tutorial
The method for it is event.stopPropagation() . For instance, here body.onclick doesn't work if you click on <button> :.
Read more >
event.stopPropagation() | jQuery API Documentation
Description: Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event. version added: 1.0event....
Read more >
Stoppropagation react typescript. preventDefault)를써도이벤트...
</button> event. typescript react function coponent props. Please note that I'll keep using yarn ... stopPropagation () seems to not be working as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found