diff --git a/src/ol/PluggableMap.js b/src/ol/PluggableMap.js index b5818bd717..892451c983 100644 --- a/src/ol/PluggableMap.js +++ b/src/ol/PluggableMap.js @@ -1007,14 +1007,16 @@ class PluggableMap extends BaseObject { originalEvent.clientY ); if ( + // Abort if the target is a child of the container for elements whose events are not meant + // to be handled by map interactions. + this.overlayContainerStopEvent_.contains(target) || // Abort if the event target is a child of the container that is no longer in the page. // It's possible for the target to no longer be in the page if it has been removed in an // event listener, this might happen in a Control that recreates it's content based on // user interaction either manually or via a render in something like https://reactjs.org/ - !rootNode.contains(target) || - // Abort if the target is a child of the container for elements whose events are not meant - // to be handled by map interactions. - this.overlayContainerStopEvent_.contains(target) + !(rootNode === document ? document.documentElement : rootNode).contains( + target + ) ) { return; }