From 519302b53d0dec61a5ac6756c0792f6db6183b20 Mon Sep 17 00:00:00 2001 From: David Larlet Date: Thu, 6 Feb 2025 11:14:58 -0500 Subject: [PATCH] fix: Do not error when escape during marker creation Co-authored-by: Yohan Boniface --- 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 61c43413..b992a75c 100644 --- a/umap/static/umap/js/umap.controls.js +++ b/umap/static/umap/js/umap.controls.js @@ -1029,6 +1029,9 @@ U.Editable = L.Editable.extend({ onEscape: function () { this.once('editable:drawing:end', (event) => { this._umap.tooltip.close() + // When hitting Escape before adding a marker, + // it tries to edit an unconnected marker. + if (event?.layer?.feature?.datalayer === null) return // Leaflet.Editable will delete the drawn shape if invalid // (eg. line has only one drawn point) // So let's check if the layer has no more shape