From d54b0e94b7777ff62b8c1ea3696fb107ca2f4c96 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Wed, 3 Jan 2024 21:25:20 +0100 Subject: [PATCH] Only close ui panel if it is open When calling ui.closePanel, this will fire "panel:closed", which is listened by uMap to blindly call map.invalidateSize, which creates trouble in the dashboard preview: when pressing twice ESC key (eg. when switching from a preview to another), the map would pan once to the north east (I guess because invalidateSize is called while the map is not displayed, but not sure). --- umap/static/umap/js/umap.ui.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/umap/static/umap/js/umap.ui.js b/umap/static/umap/js/umap.ui.js index 501ec3d2..053b4b53 100644 --- a/umap/static/umap/js/umap.ui.js +++ b/umap/static/umap/js/umap.ui.js @@ -64,8 +64,10 @@ L.U.UI = L.Evented.extend({ }, closePanel: function () { - L.DomUtil.removeClass(this.parent, 'umap-ui') - this.fire('panel:closed') + if (L.DomUtil.hasClass(this.parent, 'umap-ui')) { + L.DomUtil.removeClass(this.parent, 'umap-ui') + this.fire('panel:closed') + } }, alert: function (e) {