fix(MessageBar): Fix IME language handling #633
Merged
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.
Languages that rely on IME keyboards may use the enter key for final text selection on Mac. The MessageBar also uses enter key for submit. The result was that IME input, such as Japanese, was prematurely submitted. I added an additional check for whether the onCompositionEnd event is complete and also added some additional handling for Safari, which is a little bit of a special case. This should resolve the issue on Mac. I manually checked Edge, Chrome, Safari, and Firefox on my machine with a Japanese keyboard.
Assisted-by: Cursor (used to generate boilerplate for handleCompositionStart/End, etc.)
https://www.stum.de/2016/06/24/handling-ime-events-in-javascript/ helped me resolve the issue with Safari - we have to use "which" for now - the less-deprecated ways of checking just register an "Enter" key press with a different "which" value of 13. We want the 229 value.
Screen.Recording.2025-07-30.at.11.29.12.AM.mov
Turned on VoiceOver to see what would happen and it also seems to pick up the Japanese text in the VO announcements.
Tami Takamiya said this doesn't break him on Fedora - he was able to use Japanese successfully with the MessageBar prior to this change on Fedora 42 Workstation and after this change.
Don Labaj pulled up a Windows VM and it also seemed unaffected by this issue, but wasn't impacted by this change either. Same with when I tried on my Samsung phone.
Instructions on setting up Japanese keyboard on Mac: https://support.apple.com/guide/japanese-input-method/set-up-the-input-source-jpim10267/mac