Components: Resolving unintended key events in IME composition #45605
Labels
[Package] Components
/packages/components
[Type] Tracking Issue
Tactical breakdown of efforts across the codebase and/or tied to Overview issues.
Related to: #45510, #45599
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.
space
orup/down
keys to move through the list of candidates.delete
orbackspace
key to delete characters before or after the current cursor positionenter
key to confirm your input.escape
key 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 ProcessTherefore, in components that accept text input and use
event.code
, I believe it is appropriate to rewrite them usingevent.key
.@edit: It turns out that simply replacing
event.code
withevent.key
is insufficient. As noted in this comment, it would be desirable to add checks forevent.isComposing
andevent.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 enteredComboboxControl
: When theenter
key is pressed, both candidate characters and typed characters may be inserted.Modal
: Pressing theescape
key to cancel the input state causes the modal to disappear.AutocompleteUI
: Forward slash inserter doesn't work in JapaneseTokenInput
component (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 theescape
key to cancel the input state causes the modal to disappear.Guide
: Pressing theescape
key to cancel the input state causes the modal to disappear.The text was updated successfully, but these errors were encountered: