From 724540a8b2981ff4857edf105eb448bececaf444 Mon Sep 17 00:00:00 2001 From: Maximilian Mader Date: Wed, 22 Aug 2018 19:10:10 +0200 Subject: [PATCH] Fix enter key check while composing characters Chrome on macOS sends a KeyEvent with `key` set to `Enter`, the keyCode `229` and `isComposing` set to `true` when pressing enter while a character composition sequence is active, then an event for the composed key and ends with a Enter key event with the correct key code. This has thrown our Enter key detection off and resulted in sending of the wanted message and a public message with the single composed character as content. Ignoring the Enter key while characters are being composed seems to be safe. --- files_wcf/js/Bastelstu.be/Chat/Ui/Input.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/files_wcf/js/Bastelstu.be/Chat/Ui/Input.js b/files_wcf/js/Bastelstu.be/Chat/Ui/Input.js index dfe4f2c..ea5cedf 100644 --- a/files_wcf/js/Bastelstu.be/Chat/Ui/Input.js +++ b/files_wcf/js/Bastelstu.be/Chat/Ui/Input.js @@ -4,7 +4,7 @@ * Use of this software is governed by the Business Source License * included in the LICENSE file. * - * Change Date: 2022-08-16 + * Change Date: 2022-08-22 * * On the date above, in accordance with the Business Source * License, use of this software will be governed by version 2 @@ -47,6 +47,11 @@ define([ '../console' handleInputKeyDown(event) { if (EventKey.Enter(event) && !event.shiftKey) { + if (event.isComposing) { + console.debug('Ui/Input.handleInputKeyDown', 'Ignored Enter key while composing characters.') + return + } + // prevent generation of a new line event.preventDefault()