From 122d470e31fa0047118be297325a938c46affaa4 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Tue, 21 Jan 2025 18:19:16 +0100 Subject: [PATCH] fix: do not consume ctrl-Z in textarea or input fix #2422 --- umap/static/umap/js/modules/umap.js | 8 +++++++- umap/static/umap/js/modules/utils.js | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/umap/static/umap/js/modules/umap.js b/umap/static/umap/js/modules/umap.js index ab4d94fe..c60b7e28 100644 --- a/umap/static/umap/js/modules/umap.js +++ b/umap/static/umap/js/modules/umap.js @@ -541,7 +541,13 @@ export default class Umap extends ServerStored { if (SAVEMANAGER.isDirty) this.saveAll() break case 'z': - if (SAVEMANAGER.isDirty) this.askForReset() + if (Utils.isWritable(event.target)) { + used = false + break + } + if (SAVEMANAGER.isDirty) { + this.askForReset() + } break case 'm': this._leafletMap.editTools.startMarker() diff --git a/umap/static/umap/js/modules/utils.js b/umap/static/umap/js/modules/utils.js index b36bc840..bf4b3e3c 100644 --- a/umap/static/umap/js/modules/utils.js +++ b/umap/static/umap/js/modules/utils.js @@ -465,6 +465,12 @@ export class WithEvents { } } +export function isWritable(element) { + if (['TEXTAREA', 'INPUT'].includes(element.tagName)) return true + if (element.isContentEditable) return true + return false +} + export const COLORS = [ 'Black', 'Navy',