From f95a93860a41bcbe83bdb6994683b2e93ba6b1b5 Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Fri, 18 Aug 2023 15:54:45 +0530 Subject: [PATCH] fix: prevent back if editing - remove duplicate beforeCancel --- fyo/model/doc.ts | 1 - src/utils/vueUtils.ts | 10 ++++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/fyo/model/doc.ts b/fyo/model/doc.ts index 605194f5..a5b23b6d 100644 --- a/fyo/model/doc.ts +++ b/fyo/model/doc.ts @@ -951,7 +951,6 @@ export class Doc extends Observable { return; } - await this.trigger('beforeCancel'); await this.trigger('beforeCancel'); await this.setAndSync('cancelled', true); await this.trigger('afterCancel'); diff --git a/src/utils/vueUtils.ts b/src/utils/vueUtils.ts index 9f46ae23..8458f173 100644 --- a/src/utils/vueUtils.ts +++ b/src/utils/vueUtils.ts @@ -31,9 +31,15 @@ export function useKeys() { }); const keydownListener = (e: KeyboardEvent) => { + const notMods = !(e.altKey || e.metaKey || e.ctrlKey); + if (e.target instanceof HTMLInputElement && notMods) { + return; + } + if ( - e.target instanceof HTMLInputElement && - !(e.altKey || e.metaKey || e.ctrlKey) + e.target instanceof HTMLElement && + e.target.contentEditable === 'true' && + notMods ) { return; }