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.
This commit is contained in:
Yohan Boniface 2025-04-11 11:49:37 +02:00 committed by David Larlet
parent dc35e7df6d
commit 581140e08a
No known key found for this signature in database
GPG key ID: 3E2953A359E7E7BD

View file

@ -418,6 +418,10 @@ export class DataLayer {
removeFeature(feature, sync) { removeFeature(feature, sync) {
const id = stamp(feature) 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) { if (sync !== false) {
const oldValue = feature.toGeoJSON() const oldValue = feature.toGeoJSON()
feature.sync.delete(oldValue) feature.sync.delete(oldValue)