fix: Do not error when escape during marker creation (#2483)

This commit is contained in:
David Larlet 2025-02-06 11:28:26 -05:00 committed by GitHub
commit 0cba3ab158
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1029,6 +1029,9 @@ U.Editable = L.Editable.extend({
onEscape: function () { onEscape: function () {
this.once('editable:drawing:end', (event) => { this.once('editable:drawing:end', (event) => {
this._umap.tooltip.close() 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 // Leaflet.Editable will delete the drawn shape if invalid
// (eg. line has only one drawn point) // (eg. line has only one drawn point)
// So let's check if the layer has no more shape // So let's check if the layer has no more shape