commit 09035689cf29d48af5804ee8f019f73576f0b462 parent 25bd94299a879dda8600580af045f9eb92ca566f Author: Sergej Orlov <wladimirych@gmail.com> Date: Sun, 24 May 2026 22:25:42 +0200 polyline-edit: do not ignore keypress when non-text input has focus Also handle Esc (stop editing) even when text input has focus Fixes #1189 Diffstat:
| M | src/lib/leaflet.polyline-edit/index.js | | | 16 | ++++++++++------ |
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/src/lib/leaflet.polyline-edit/index.js b/src/lib/leaflet.polyline-edit/index.js @@ -163,13 +163,17 @@ L.Polyline.EditMixin = { }, onKeyPress: function(e) { - if (e.target.tagName.toLowerCase() === 'input') { + const code = e.keyCode; + const targetTag = e.target.tagName.toLowerCase(); + const isTargetTextInput = (targetTag === 'input' && e.target.type.toLowerCase() === 'text') || + targetTag === 'textarea'; + if (code !== 27 && isTargetTextInput) { return; } - var code = e.keyCode; + switch (code) { - case 27: - case 13: + case 27: // Escape + case 13: // Enter if (this._drawingDirection) { this.stopDrawingLine(); } else { @@ -179,8 +183,8 @@ L.Polyline.EditMixin = { } L.DomEvent.stop(e); break; - case 8: - case 46: + case 8: // Backspace + case 46: // Delete if (this._drawingDirection && this.getLatLngs().length > 2) { const nodeIndex = this._drawingDirection === 1 ? this.getLatLngs().length - 2 : 1; this.removeNode(nodeIndex);
