From 581140e08a2e651e016fdf426b124b7dbe3e1c14 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 11 Apr 2025 11:49:37 +0200 Subject: [PATCH] fix: do not try to remove a feature not yet added cf #2625 This happens while drawing a line or polygon and then hitting escape while the path is not yet valid. --- umap/static/umap/js/modules/data/layer.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/umap/static/umap/js/modules/data/layer.js b/umap/static/umap/js/modules/data/layer.js index 7dc03e8f..617fea1a 100644 --- a/umap/static/umap/js/modules/data/layer.js +++ b/umap/static/umap/js/modules/data/layer.js @@ -418,6 +418,10 @@ export class DataLayer { removeFeature(feature, sync) { const id = stamp(feature) + // This feature was not yet added, may be after + // hitting Escape while drawing a new line or + // polygon, not yet valid (not enough points) + if (!this._index.includes(id)) return if (sync !== false) { const oldValue = feature.toGeoJSON() feature.sync.delete(oldValue)