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.

onClick handler not fired on children

See original GitHub issue
<Link to='/home' onClick={this.onItemClick}>
  <i className="fa fa-file"></i>   
  <span id='works'>Click me - I work!!</span>
  <Highlighter search={this.props.query} caseSensitive={false}>
    {this.props.name}
  </Highlighter>
</Link>

this.onItemClick is only invoked when clicking on span#works. However, clicking any of the elements from Highlighter doesn’t actually propagate the event in any way. I’ve found that it does work when I remove {'key': this.count} from the children in the array.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:3
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ericgiocommented, Oct 29, 2017

As a workaround, you can set pointer-events: none on the highlighter component.

0reactions
janmylercommented, Aug 30, 2017

There’s a PR open https://github.com/helior/react-highlighter/pull/46 to fix it, however, it usually takes a rather long time to get anything merged.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ReactJS: onClick handler not firing when placed on a child ...
I have a question regarding placing onClick event listeners in child components. As you can see from the code sample below, I have...
Read more >
ourstytems Child Container onClick event trigger the parent ...
Hi,. In a Mobile application Screen I have a Parent Container & Child Container under it. For both Container I added the onClick...
Read more >
Element: click event - Web APIs | MDN
click fires after both the mousedown and mouseup events have fired, in that order. Syntax. Use the event name in methods like addEventListener() ......
Read more >
JavaScript: Preventing Parent Event When Child Event Is ...
When the onClick is triggered in my child element, I want to stop the propagation to my parent element's onClick event.
Read more >
Event Bubbling and Event Catching in JavaScript and React
Once an inner child element's event is called, all elements above/below it will also be called (bubbling/capturing). To stop this from happening ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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