Skip to content

fix(ui): guard Enter key handlers against IME composition#66392

Open
okxint wants to merge 1 commit into
PostHog:masterfrom
okxint:fix/ime-composition-enter-key
Open

fix(ui): guard Enter key handlers against IME composition#66392
okxint wants to merge 1 commit into
PostHog:masterfrom
okxint:fix/ime-composition-enter-key

Conversation

@okxint

@okxint okxint commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Problem

Pressing Enter to confirm an IME candidate (Japanese, Chinese, Korean, etc.) also fires the surrounding action — creating an org, adding a tag, saving a field title, etc. Reported in #60044.

Root cause in LemonInput: the internal onKeyDown handler has the isComposing guard but is overridden by {...props} spread immediately after, so consumers using the onKeyDown prop bypass the guard entirely.

Changes

LemonInput — destructures onKeyDown from props and calls it from inside the merged handler. Enter events during IME composition return early before either onPressEnter or the consumer's handler fires.

LemonTextArea — already merged its consumer onKeyDown, but didn't early-return on composition, so the consumer handler still fired. Now returns early on Enter+isComposing.

LemonInputSelect — adds the guard before the "add tag on Enter" path.

EditableField — adds the guard before the "save on Enter" path.

Closes #60044

How did you test this code?

Agent-authored. The fix is mechanically straightforward — event.nativeEvent.isComposing is the standard web API guard for this. Verified the four changed files match the pattern used in the existing working path (onPressEnter in LemonInput).

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Docs update

N/A

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Traced the root cause to the {...props} spread pattern overriding the internal onKeyDown, consistent with the diagnosis in the issue. Fixed by merging handlers rather than replacing them, and added early-return guards at the specific high-impact call sites listed in the issue.

…t components

LemonInput was overriding its internal onKeyDown (which had the isComposing
guard) with the consumer's onKeyDown via props spread, so the guard never
applied when consumers used the lower-level onKeyDown prop. fix: destructure
consumer's onKeyDown and call it from within the merged handler, skipping
Enter during composition.

LemonTextArea already called consumer's onKeyDown after the guard, but did
not early-return on composition so the consumer handler still fired on Enter
during IME. fixed to return early.

also add the guard to LemonInputSelect (tag-add on Enter) and EditableField
(save on Enter), two of the highest-impact call sites listed in PostHog#60044.
@greptile-apps

greptile-apps Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix(ui): guard Enter key handlers agains..." | Re-trigger Greptile

Comment on lines +561 to +563
if (e.key === 'Enter' && e.nativeEvent.isComposing) {
return // IME candidate confirmation — don't add a tag
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Redundant guard — never reached

Because _onKeyDown is passed as the onKeyDown prop to LemonInput, and LemonInput's merged handler now returns early on Enter + isComposing before it calls consumerOnKeyDown?.(event), this guard in _onKeyDown is dead code: LemonInput will always swallow the IME-Enter event before _onKeyDown is ever invoked. The protection the comment describes is already provided one layer up.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(ui): Enter key submits forms while typing in Japanese, Chinese, or Korean (IME composition)

1 participant