Detecting clicks outside of a tooltip – `handleOutsideClick` fires after unmounting (IE only)
See original GitHub issueI’ve found a very specific scenario in which handleOutsideClick
function is fired when the Tooltip
component is unmounted.
In my web app (using react
, redux
and react-redux-router
) I have a button which acts as a tooltip trigger (trigger mode is set to “click”) and a button which executes history.push
. Due to the routing, navigating through the app using “push” won’t reenter the app but only unmounts some components and mounts another. In IE 11 when the user clicks on the second button when the tooltip is shown react unmounts parent component, buttons and hence the TooltipTrigger
and the Tooltip
components. The handleOutsideClick
event handler is removed, but (only in IE) the code in the handler is executed which leads to exception because findDOMNode
cannot be used on unmounted components.
In my opinion, the simplest solution is to check whether the component is mounted before calling findDOMNode
. I don’t have any idea why the handler is called after removing the event listener.
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
Hi, I have released v2.8.1-alpha.1 with a check for mount state before findDOMNode on outside click. Please give it a spin and let me know if anything is missing.
Fix now available in v2.8.1