From b749243de02286b92e76fa9c87c0abf8cad0bb3a Mon Sep 17 00:00:00 2001 From: Jarkko Linnanvirta Date: Fri, 20 May 2022 14:56:49 +0300 Subject: [PATCH] #216: SC_Modal: Fix pressing 'Enter' in a modal causes newlines to be inserted into a note. --- src/SC_Modal.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/SC_Modal.ts b/src/SC_Modal.ts index 75623bf0..90ee1754 100644 --- a/src/SC_Modal.ts +++ b/src/SC_Modal.ts @@ -35,7 +35,7 @@ export abstract class SC_Modal extends Modal { // Approve the modal by pressing the enter key (if enabled). if (this.plugin.settings.approve_modals_by_pressing_enter_key) { - this.scope.register([], "enter", () => { + this.scope.register([], "enter", (event: KeyboardEvent) => { // Check that no textarea is focused and no autocomplete menu is open. if ( 0 === document.querySelectorAll("textarea:focus").length && @@ -43,6 +43,8 @@ export abstract class SC_Modal extends Modal { ) { // No textareas with focus and no open autocomplete menus were found. this.approve(); + event.preventDefault(); + event.stopPropagation(); } }); }