From f81681f957c056db0d14dab994b4a9d79dca1fd1 Mon Sep 17 00:00:00 2001 From: AliyanH Date: Tue, 24 Jan 2023 16:03:37 -0500 Subject: [PATCH] update keydown event listener and fix query handler bug --- src/mapml-viewer.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mapml-viewer.js b/src/mapml-viewer.js index b5b58e930..f7800bef8 100644 --- a/src/mapml-viewer.js +++ b/src/mapml-viewer.js @@ -347,16 +347,17 @@ export class MapViewer extends HTMLElement { } }); // pasting layer-, links and geojson using Ctrl+V - this.parentElement.addEventListener('keydown', function (e) { - if(e.keyCode === 86 && e.ctrlKey && document.activeElement.nodeName === "MAPML-VIEWER"){ + this.addEventListener('keydown', function (e) { + if(e.keyCode === 86 && e.ctrlKey){ navigator.clipboard .readText() .then( (layer) => { - M._pasteLayer(document.activeElement, layer); + M._pasteLayer(this, layer); }); - } else if (e.keyCode === 32 && document.activeElement.nodeName === "MAPML-VIEWER") { + } else if (e.keyCode === 32) { e.preventDefault(); + this._map.fire('keypress', {originalEvent: e}); }}); this.parentElement.addEventListener('mousedown', function (e) { if(document.activeElement.nodeName === "MAPML-VIEWER"){