Repository navigation
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
keyupwith key code 13 and then calledremoveLastChar, 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
Processin Chrome and Edge on Windows,isComposingin Chrome on macOS, key code 229 aftercompositionendin 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
keydownand ignored whileisComposingis set or the key code is 229.preventDefaultstops the newline, so the text is submitted exactly as typed andremoveLastCharis no longer needed. Shift+Enter still inserts a newline, and an empty reply is still not submitted.Test
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 currentdevelop, the composing case fails withExpected spy emit not to have been called.andExpected '我同意你的看' to equal '我同意你的看法'.isComposingor the 229 check makes one of the new cases fail.