From 50b8b66261898efead0420a85bfdf4d3bf531f98 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Mon, 31 Jul 2023 20:58:25 +0200 Subject: [PATCH 1/2] Simplify Panel popup inheritance Panel is not a real popup, so the less we inherit the better --- umap/static/umap/js/umap.popup.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/umap/static/umap/js/umap.popup.js b/umap/static/umap/js/umap.popup.js index 173cba39..9fd96b3c 100644 --- a/umap/static/umap/js/umap.popup.js +++ b/umap/static/umap/js/umap.popup.js @@ -63,8 +63,8 @@ L.U.Popup.Panel = L.U.Popup.extend({ return button }, - update: function () { - this.feature.map.ui.openPanel({ + onAdd: function (map) { + map.ui.openPanel({ data: { html: this._content }, actions: [this.allButton()], }) @@ -72,12 +72,9 @@ L.U.Popup.Panel = L.U.Popup.extend({ onRemove: function (map) { map.ui.closePanel() - L.U.Popup.prototype.onRemove.call(this, map) }, - _initLayout: function () { - this._container = L.DomUtil.create('span') - }, + update: function () {}, _updateLayout: function () {}, _updatePosition: function () {}, _adjustPan: function () {}, From 3115038ba6c875a5184fcabf6bf443bdb075487d Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Mon, 31 Jul 2023 20:59:09 +0200 Subject: [PATCH 2/2] Fix popup panel not opening from the data browser The issue was: - clicking on feature in the data browser replaces the panel content - then the clicked link (the feature name or the little glass icon) is removed - thus it is detached from the DOM - and specially from its parent on which disableClickPropagation was called - so Leaflet fails to prevent click propagation - so the map received the click, and thus it call the onRemove method on the panel, as expected (clicking on the map always close the current open popup, if any) This could be removed when this is released: https://github.com/Leaflet/Leaflet/pull/9052 --- umap/static/umap/js/umap.controls.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/umap/static/umap/js/umap.controls.js b/umap/static/umap/js/umap.controls.js index 0c1bc9c1..06fd9e14 100644 --- a/umap/static/umap/js/umap.controls.js +++ b/umap/static/umap/js/umap.controls.js @@ -671,6 +671,9 @@ L.U.DataLayer.addInitHook(function () { L.U.Map.include({ _openBrowser: function () { const browserContainer = L.DomUtil.create('div', 'umap-browse-data') + // HOTFIX. Remove when this is merged and released: + // https://github.com/Leaflet/Leaflet/pull/9052 + L.DomEvent.disableClickPropagation(browserContainer) const title = L.DomUtil.add( 'h3',