Use document.body to check if an event target is within the page

Some events will originate outside the map viewport such as keyboard
events which originate with the element specified by keyboardEventTarget
which could be document.body
This commit is contained in:
Matt Walker
2020-01-13 10:56:41 +00:00
parent 5ce532e3e4
commit 4e599a370b

View File

@@ -934,7 +934,7 @@ class PluggableMap extends BaseObject {
}
const target = /** @type {Node} */ (mapBrowserEvent.originalEvent.target);
if (!mapBrowserEvent.dragging) {
if (this.overlayContainerStopEvent_.contains(target) || !this.viewport_.contains(target)) {
if (this.overlayContainerStopEvent_.contains(target) || !document.body.contains(target)) {
// Abort if the event target is a child of the container that doesn't allow
// event propagation or 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