Skip to content

fix(ClassResponse): Enter that confirms an IME candidate posts the comment - #2397

Open
Isaries wants to merge 1 commit into
WISE-Community:developfrom
Isaries:fix/discussion-reply-ime-enter
Open

Isaries wants to merge 1 commit into
WISE-Community:developfrom
Isaries:fix/discussion-reply-ime-enter

Conversation

@Isaries

@Isaries Isaries commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

When a student replies in a Discussion using an input method editor (Chinese, Japanese), the Enter that confirms a candidate posts the comment, and the last character of the comment is removed. The reply box submitted on keyup with key code 13 and then called removeLastChar, on the assumption that the Enter had just inserted a newline.

With an IME, the confirming Enter is consumed by the composition 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, key code 229 after compositionend in Safari), but the matching keyup arrives after the composition has ended with key code 13. So the unfinished comment is posted the moment the student confirms a word, and its last real character, usually the word just confirmed, is cut off. Students who type in these languages cannot write more than one word per comment with the keyboard.

Changes

  • Enter is handled on keydown and ignored while isComposing is set or the key code is 229.
  • preventDefault stops the newline, so the text is submitted exactly as typed and removeLastChar is no longer needed. Shift+Enter still inserts a newline, and an empty reply is still not submitted.

Test

  • New cases in class-response.component.spec.ts: composing Enters as reported on Windows (Process/229 keydown, then keyup 13), in Chrome on macOS (isComposing) and in Safari (229) do not submit and leave the text intact; a plain Enter submits text ending in a CJK character with no character removed; Shift+Enter does not submit. Against the current develop, the composing case fails with Expected spy emit not to have been called. and Expected '我同意你的看' to equal '我同意你的看法'.
  • Removing either the isComposing or the 229 check makes one of the new cases fail.

…mment

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant