Repository navigation
Description
Problem
Text-input components that handle keydown (Enter/Escape/arrows) can misfire while an IME (Korean/Japanese/Chinese) composition is live. Pressing Enter to commit a composition is misread as a command (accept suggestion, save, submit), because the browser fires keydown with isComposing: true (or legacy keyCode: 229) BEFORE compositionend writes the pending syllable.
This has now been fixed reactively in three places, one at a time:
ChatComposerInput(earliest)BaseTypeahead— and everything built on it (Typeahead, Tokenizer, PowerSearch free-text search) — via fix(Typeahead): guard Enter/Escape/arrow keys against IME composition #4860 (closes [Bug] PowerSearch: Enter during IME composition splits the last character into a separate filter #4828)PowerSearchEditPopover's Enter-to-save (also fix(Typeahead): guard Enter/Escape/arrow keys against IME composition #4860)
The shared helper already exists: isImeKeyEvent in useFocusTrap.ts. The gap is that there's no systematic guarantee every keydown-handling text input uses it — each site has been patched only after a user hit the bug.
Goal
Make IME-composition safety a property we enforce, not a bug we keep rediscovering. Audit every component that reads Enter/Escape/arrow/Home/End on a text input or contenteditable and confirm it guards with isImeKeyEvent (or equivalent). Candidates to check beyond the three already fixed: TextArea/TextInput (if they have keydown commit behavior), SearchInput, ComboBox/Selector search fields, NumberInput, DateTimeInput segment editing, CommandPalette input, any Chat inputs, and anything else consuming onKeyDown on an editable surface.
Possible approaches (decide during investigation)
- A lint rule — flag
onKeyDownhandlers on text inputs that referencee.key === 'Enter'/'Escape'/arrow keys without anisImeKeyEvent/isComposingguard. Highest leverage; catches new code (incl. AI-generated) at author time. - An interaction test / audit dimension — fire a composing Enter (
isComposing: trueandkeyCode: 229) at each text-input component and assert it does NOT trigger the command action, then a real Enter does. Mirrors how fix(Typeahead): guard Enter/Escape/arrow keys against IME composition #4860 tested it. - A shared input primitive/hook that bakes in the guard, so components can't forget it.
Context
Not an RTL bug (CJK is LTR) and not caught by the pr-rtl audit, which is scoped to layout-direction geometry. This is the input-method dimension of i18n — a distinct class the current tooling doesn't cover. Surfaced by @cixzhang. Related reactive fixes: #4860, #4828.
Activity
nynexman4464 commentedon Aug 11, 2026
Investigation findings
Audited every
onKeyDown/handleKeyDownsite inpackages/core/srcthat branches on command keys (Enter/Escape/arrows/Home/End) and attaches to an editable surface (<input>/<textarea>/contentEditable). Filtered out non-editable keydown sites (buttons, menus, tabs, calendar cells) where an IME can't run.Confirmed same-class bugs (unguarded free-text input)
TextInput'sonKeyDownforwardsEnter/Escapestraight to the shared handler (Selector/hooks.ts), which selects the highlighted option / closes the popover. NoisComposing/isImeKeyEventguard. A CJK user committing a composition with Enter selects an option instead of committing text. Direct analogue of fix(Typeahead): guard Enter/Escape/arrow keys against IME composition #4860.Enter/Escapeforward.Lower risk (guard is cheap + consistent, but low real-world exposure)
type="number"; IMEs don't compose CJK text into number fields.useTriggerMenu— operates on a contenteditable; worth confirming its Enter/Escape can't fire mid-composition.Ruled out
Already guarded
ChatComposerInput, BaseTypeahead (+Typeahead/Tokenizer/PowerSearch via #4860), Tooltip, Dialog.
Conclusion
This is a "no mechanism prevents the next one" problem, not a "find the last few sites" problem — Selector + MultiSelector shipped the same gap after Typeahead was fixed, because nothing enforces the guard. Highest-leverage fix = approach 1 (lint rule): flag any
onKeyDownon an editable surface that branches on Enter/Escape/arrows without anisComposing/isImeKeyEventguard. That catches Selector, MultiSelector, and every future component (incl. AI-generated) at author time.Also evaluating consolidating the 4 existing ad-hoc guards (
isImeKeyEventinuseFocusTrap.ts+ inlineisComposingchecks) into a single shared primitive so the lint rule has one canonical thing to point at.feat(lint): @astryx/no-unguarded-ime-keydown
feat(lint): @astryx/no-unguarded-ime-keydown
feat(lint): @astryx/no-unguarded-ime-keydown
feat(lint): @astryx/no-unguarded-ime-keydown
feat(lint): @astryx/no-unguarded-ime-keydown
feat(lint): @astryx/no-unguarded-ime-keydown — enforce IME compositio…