From 871a36f7a2cba4e935919910fa0cfbb266c4b4e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Tue, 25 May 2021 14:26:32 +0200 Subject: [PATCH] MOBILE-3320 core: Prevent new line to be shown before submit --- .../core-send-message-form.html | 20 +++++++++++++--- .../send-message-form/send-message-form.ts | 23 ++++++++++++++++++- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/core/components/send-message-form/core-send-message-form.html b/src/core/components/send-message-form/core-send-message-form.html index 066072909..292f9c2f2 100644 --- a/src/core/components/send-message-form/core-send-message-form.html +++ b/src/core/components/send-message-form/core-send-message-form.html @@ -1,7 +1,21 @@
- + diff --git a/src/core/components/send-message-form/send-message-form.ts b/src/core/components/send-message-form/send-message-form.ts index aaa69d383..a783732ad 100644 --- a/src/core/components/send-message-form/send-message-form.ts +++ b/src/core/components/send-message-form/send-message-form.ts @@ -103,13 +103,34 @@ export class CoreSendMessageFormComponent implements OnInit { this.onResize.emit(); } + /** + * A11y key functionality that prevents keyDown events. + * + * @param e Event. + */ + enterKeyDown(e: KeyboardEvent, other?: string): void { + if (this.sendDisabled) { + return; + } + + if (this.sendOnEnter && !other) { + // Enter clicked, send the message. + e.preventDefault(); + e.stopPropagation(); + } else if (!this.sendOnEnter && !CoreApp.isMobile() && other == 'control') { + // Cmd+Enter or Ctrl+Enter, send message. + e.preventDefault(); + e.stopPropagation(); + } + } + /** * Enter key clicked. * * @param e Event. * @param other The name of the other key that was clicked, undefined if no other key. */ - enterClicked(e: Event, other?: string): void { + enterKeyUp(e: Event, other?: string): void { if (this.sendDisabled) { return; }