From aade75ded88e631947bc9a9a45c3621593442097 Mon Sep 17 00:00:00 2001 From: Isaries Date: Fri, 20 Nov 2026 14:23:47 +0800 Subject: [PATCH] fix(ClassResponse): Enter that confirms an IME candidate posts the comment The discussion comment box submitted on keyup when the key code was 13, then removed the last character on the assumption that it was the newline the Enter key had just inserted. When a student types Chinese or Japanese with an IME, the Enter that confirms a candidate is consumed by the IME and inserts no newline. Its keydown is reported as composing (key code 229 with key 'Process' in Chrome and Edge on Windows, isComposing in Chrome on macOS, and key code 229 after compositionend in Safari), but the matching keyup arrives after compositionend with key code 13. The unfinished comment was therefore posted as soon as the student confirmed a word, and its last real character was removed instead of a newline. Handle Enter on keydown instead, ignore it while isComposing is set or the key code is 229, and prevent the default so no newline is inserted. The text is then submitted exactly as typed and no character needs to be removed. --- .../class-response.component.html | 2 +- .../class-response.component.spec.ts | 60 +++++++++++++++++++ .../class-response.component.ts | 21 +++---- 3 files changed, 70 insertions(+), 13 deletions(-) diff --git a/src/assets/wise5/components/discussion/class-response/class-response.component.html b/src/assets/wise5/components/discussion/class-response/class-response.component.html index ddf747bb958..0a5775cafe6 100644 --- a/src/assets/wise5/components/discussion/class-response/class-response.component.html +++ b/src/assets/wise5/components/discussion/class-response/class-response.component.html @@ -71,7 +71,7 @@