Recently, I have integrated Material Design Lite into my React web application. For the most part, everything worked out very well, but I am currently having some problems with React event handling, which seem to be not very pleasant with some MDL components.
In particular, I have a DOM element with an onClick handler that works fine until an MDL tooltip is added, which is why onClick no longer works. I tried almost all possible options (put the tooltip in another place in the DOM, attach the onClick handler to the div container that has the tooltip as a child, etc.), and I just can't get it working.
Here's a JSBin demonstrating the problem (I also included an example that uses jQuery to bind a click handler to an element after mounting components, which actually works):
http://jsbin.com/sewimi/3/edit?js,output
I have some theories as to why this doesn't work, but I don't know enough about React or MDL to test them.
I believe this has something to do with how React handles events, and for some reason MDL seems to be facing this. In the documentation:
React does not actually attach event handlers to the nodes themselves. When React launches, it starts listening for all the events above using a single event listener. When a component is mounted or unmounted, event handlers are simply added or removed from the internal mapping. When an event occurs, React knows how to send it using this mapping. When there are no mapping event handlers in the event handler, React event handlers are simple no-ops
It looks like MDL can ruin the internal display of React events, which leads to the fact that my click on an element becomes no-op. But then again, this is just a complete hunch.
Does anyone have any ideas about this? I would prefer not to manually bind the event listener in componentDidMount for each of my components that use MDL hints (as was the case in the JSBin example that I provided), but this is the solution I'll show right now.
In addition, since I was not sure that it was an MDL error, I decided to post this question here, and not on the issues page. If someone thinks I should post it there, let me know and I can do it.
Thanks!