Repository navigation
Conversation
…acOS The item text input binds keydown.enter directly to save(). Angular matches that binding on event.key, and in Chrome on macOS and in Safari the Enter that confirms an input method editor candidate (Chinese, Japanese, Korean) arrives as a keydown with key "Enter": Chrome sets isComposing, and Safari fires it after compositionend with keyCode 229. The visible result differs by browser. In Chrome on macOS the form control only receives composed text on compositionend, so when earlier text is already in the field the dialog closes and saves that text without the candidate being confirmed; when the field is still empty, save() does nothing. In Safari the candidate is included, but the dialog closes on the first confirmation, so an entry the student is still typing is saved unfinished. Handle Enter in a new enterPressed() method that ignores the key while a composition is in progress, without calling preventDefault so the IME can still commit the text. A plain Enter calls preventDefault before saving, so the form's implicit submission does not save a second time.
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.
In a Match component that lets students add their own items, the Enter key that confirms an input method editor candidate (Chinese, Japanese, Korean) closes the "Enter Item Text" dialog. The input binds
keydown.enterstraight tosave(), and in Chrome on macOS and in Safari that Enter arrives as a keydown with keyEnter: Chrome setsisComposing, and Safari fires it aftercompositionendwith key code 229.What the student sees depends on the browser. In Chrome on macOS the form control only receives composed text on
compositionend, so when earlier text is already in the field the dialog closes and saves it without the word being confirmed; when the field is still empty, nothing happens. In Safari the candidate is included, but the dialog closes on the first confirmation, so an item the student is still typing is saved unfinished.Changes
enterPressed()method that ignores the key while a composition is in progress, without callingpreventDefault, so the IME can still commit the text.preventDefaultbefore saving, so the form's implicit submission does not save a second time.Test
add-match-choice-dialog.spec.ts: an Enter keydown withisComposingand one with key code 229 do not close the dialog and are not cancelled; a plain Enter closes it once with the text and is cancelled. Against the currentdevelop, the composing cases fail withExpected spy MatDialogRef.close not to have been called.and the plain Enter case withExpected false to be true.