-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
This tracking issue seeks to resolve the problem of events occurring in IME composition mode causing unintended behavior in some components.
What is IME composition ?
One of the input systems in which the IME composition are used is Japanese.
Because of the vast number of characters in the Japanese language ( including Kanji), it is not possible to input characters directly on a standard keyboard. Therefore, after entering "hiragana" characters, we choose which character to convert to and confirm with the Enter key.
- When you begin typing a character, an underline appears indicating that the expected character has not been finalized.
- Use the
spaceorup/downkeys to move through the list of candidates. - Use the 'left' and 'right' keys to move the cursor position.
- Press the
deleteorbackspacekey to delete characters before or after the current cursor position - Finally, press the
enterkey to confirm your input. - Press the
escapekey to hide input candidates or cancel what you are typing.
Screencast
f38e4476faa008f2cac7f10fd13c5f35.mp4
What is the problem if it is IME composition ?
The keyboard operations described above are only for finalizing characters. However, for some components, these keystrokes are monitored and may cause unintended behavior.
What is the cause and solution?
I found the following differences about key events when character input is not finalized.
event.code: returns the pressed key itselfevent.keyCode: returns the immediately preceding keyevent.key: returns the string Process
Therefore, in components that accept text input and use event.code, I believe it is appropriate to rewrite them using event.key.
@edit: It turns out that simply replacing event.code with event.key is insufficient. As noted in this comment, it would be desirable to add checks for event.isComposing and event.keyCode.
Components to be fixed
After a series of tests, I believe that the following components are causing problems and should be fixed:
-
FormTokenField: Duplicate tags are entered -
ComboboxControl: When theenterkey is pressed, both candidate characters and typed characters may be inserted. -
Modal: Pressing theescapekey to cancel the input state causes the modal to disappear. -
AutocompleteUI: Forward slash inserter doesn't work in Japanese - Follow-up fix to
TokenInputcomponent (see ComboboxControl: Fix unexpected behaviour in IME Composition #46827 ' s description)
The following components may have a lower priority because I believe that there are few cases where text input elements will be placed.
-
ConfirmDialog: Pressing theescapekey to cancel the input state causes the modal to disappear. -
Guide: Pressing theescapekey to cancel the input state causes the modal to disappear.