Skip to content

Enter key can submit text before an IME finishes composing #2237

Description

@s0up4200

What happens

Persons who write Korean, Chinese or Japanese use an input method editor (IME). The IME uses the Enter key to confirm the characters that it composed. qui listens for the Enter key on text fields and submits immediately. The submit can occur before the composed text is in the field. The person then saves an empty or an incomplete value.

Why it happens

The key handlers test only e.key === "Enter". They do not test if the IME is still composing. The browser sets isComposing to true on the key event during composition.

How to correct it

Add the composition test to each Enter handler that is on a text field:

if (e.key === "Enter" && !e.nativeEvent.isComposing) {

Where to correct it

isComposing is not used in web/src today. There are 27 Enter handlers in 15 files. Find them with this command:

grep -rn 'key === "Enter"' web/src --include="*.tsx"

Correct only the handlers on text fields. Do not correct the handlers that start a role="button" element with Enter or Space, because they are not text entry. These are examples of handlers to leave as they are: components/search/SearchResultCard.tsx:87, components/ui/multi-select.tsx:117 and pages/Search.tsx:155.

How it was found

CodeRabbit found this condition in PR #2193, on components/torrents/FilterViewsSection.tsx. That PR did not cause the condition. Thus the correction is made here, for all the applicable sites.

How to test it

Set the input source of the operating system to Korean or to Chinese. Type a name in a dialog. Push Enter to confirm the characters. The dialog must stay open. Push Enter again. The dialog must then submit.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingweb

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions