From 8624209e1b696d7110786b78e8872d98fc57163b Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Mon, 2 Dec 2024 11:12:21 +0100 Subject: [PATCH 1/2] fix: iter on the right elements after reordering layers --- umap/static/umap/js/modules/umap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/umap/static/umap/js/modules/umap.js b/umap/static/umap/js/modules/umap.js index b0696827..5c856185 100644 --- a/umap/static/umap/js/modules/umap.js +++ b/umap/static/umap/js/modules/umap.js @@ -596,7 +596,7 @@ export default class Umap extends ServerStored { const panes = this._leafletMap.getPane('overlayPane') this.datalayersIndex = [] - for (const pane of panes) { + for (const pane of panes.children) { if (!pane.dataset || !pane.dataset.id) continue this.datalayersIndex.push(this.datalayers[pane.dataset.id]) } From 35b541f2007133158c5b0a8a493241cd2658e2af Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Mon, 2 Dec 2024 11:13:58 +0100 Subject: [PATCH 2/2] chore: better naming in layer reordering --- umap/static/umap/js/modules/umap.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/umap/static/umap/js/modules/umap.js b/umap/static/umap/js/modules/umap.js index 5c856185..40cbae9c 100644 --- a/umap/static/umap/js/modules/umap.js +++ b/umap/static/umap/js/modules/umap.js @@ -1425,13 +1425,13 @@ export default class Umap extends ServerStored { row.dataset.id = stamp(datalayer) }) const onReorder = (src, dst, initialIndex, finalIndex) => { - const layer = this.datalayers[src.dataset.id] - const other = this.datalayers[dst.dataset.id] - const minIndex = Math.min(layer.getRank(), other.getRank()) - const maxIndex = Math.max(layer.getRank(), other.getRank()) - if (finalIndex === 0) layer.bringToTop() - else if (finalIndex > initialIndex) layer.insertBefore(other) - else layer.insertAfter(other) + const movedLayer = this.datalayers[src.dataset.id] + const targetLayer = this.datalayers[dst.dataset.id] + const minIndex = Math.min(movedLayer.getRank(), targetLayer.getRank()) + const maxIndex = Math.max(movedLayer.getRank(), targetLayer.getRank()) + if (finalIndex === 0) movedLayer.bringToTop() + else if (finalIndex > initialIndex) movedLayer.insertBefore(targetLayer) + else movedLayer.insertAfter(targetLayer) this.eachDataLayerReverse((datalayer) => { if (datalayer.getRank() >= minIndex && datalayer.getRank() <= maxIndex) datalayer.isDirty = true