From 1354c247b49d091b5b6f640b003694eec1db1a13 Mon Sep 17 00:00:00 2001 From: Ahmad Mamdouh Date: Thu, 8 Apr 2021 11:31:26 +0200 Subject: [PATCH] Desktop: Resolves #4766: ENTER key no longer submits dialogs when a textarea is focused. (#4777) --- .../app-cli/tests/support/plugins/dialog/src/index.ts | 3 +++ .../services/plugins/hooks/useSubmitHandler.ts | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/app-cli/tests/support/plugins/dialog/src/index.ts b/packages/app-cli/tests/support/plugins/dialog/src/index.ts index 3e83dbc55..747732a4a 100644 --- a/packages/app-cli/tests/support/plugins/dialog/src/index.ts +++ b/packages/app-cli/tests/support/plugins/dialog/src/index.ts @@ -34,11 +34,14 @@ joplin.plugins.register({ Name:
Email: +
+ Description: `); const result3 = await dialogs.open(handle3); console.info('Got result: ' + JSON.stringify(result3)); + }, }); diff --git a/packages/app-desktop/services/plugins/hooks/useSubmitHandler.ts b/packages/app-desktop/services/plugins/hooks/useSubmitHandler.ts index 894807ecd..d0f57df60 100644 --- a/packages/app-desktop/services/plugins/hooks/useSubmitHandler.ts +++ b/packages/app-desktop/services/plugins/hooks/useSubmitHandler.ts @@ -15,7 +15,13 @@ export default function(frameWindow: any, onSubmit: Function, onDismiss: Functio } if (event.key === 'Enter') { - if (onSubmit) onSubmit(); + // + // Disable enter key from submitting when a text area is in focus! + // https://github.com/laurent22/joplin/issues/4766 + // + if (frameWindow.document.activeElement.tagName != 'TEXTAREA') { + if (onSubmit) onSubmit(); + } } }