Skip to content

fix(ui): guard custom-answer textarea against IME composition Enter (#20850) - #33727

Closed
mahirhir wants to merge 1 commit into
anomalyco:devfrom
mahirhir:fix/question-dock-ime-composition
Closed

fix(ui): guard custom-answer textarea against IME composition Enter (#20850)#33727
mahirhir wants to merge 1 commit into
anomalyco:devfrom
mahirhir:fix/question-dock-ime-composition

Conversation

@mahirhir

@mahirhirmahirhir commented Jun 24, 2026

Copy link
Copy Markdown

Issue for this PR

Closes#20850

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The custom-answer textarea in the Question dock commits on Enter without checking for IME composition. So when a Japanese/Chinese/Korean input method confirms a candidate with Enter, that Enter gets eaten as a submit and the half-composed text is sent as the answer instead of finishing the word.

The fix is the same guard already merged here in #16361 and used in prompt-input.tsx: bail out of the keydown handler while event.isComposing is true, plus the keyCode === 229 fallback that older WebKit reports while the IME is active. During composition the Enter just confirms the candidate; only a non-composing Enter commits.

I pulled the keydown logic out of the inline closure into a small pure function (customInputKeyAction) so it could actually be unit-tested — the handler had no coverage before. The order of the existing checks (Escape, Cmd/Ctrl, Shift+Enter, plain Enter) is unchanged; the only new branch is the composition guard. It's the identical pattern the repo already accepted for the comment editor, and the tests fail on the old behavior and pass on the new one.

How did you verify your code works?

Added session-question-dock.test.ts (7 cases). The two IME cases — isComposing, and the keyCode === 229 fallback — return "commit" without the guard (the bug) and "ignore" with it. Ran the whole composer dir: 19 pass / 0 fail, no regressions. Typecheck is clean on the changed files.

bun test --conditions=browser --preload ./happydom.ts ./src/pages/session/composer/session-question-dock.test.ts

Screenshots / recordings

No visual change — this is keydown behavior, covered by the unit tests above rather than a screenshot.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

The custom-answer textarea in SessionQuestionDock committed the answer when
Enter was pressed to confirm a CJK IME candidate (Japanese/Chinese/Korean),
because its keydown handler did not check `isComposing`/`keyCode === 229`.
Composition-confirm Enter now only commits the composed character.
Extracts the keydown decision into a pure `customInputKeyAction` helper
(behavior otherwise unchanged) and adds unit tests covering the IME guard.
Matches the existing IME guards in prompt-input.tsx and line-comment.tsx.
Closes #20850
@github-actionsgithub-actionsBot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Jun 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Sign up for freeto 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] Question dock custom answer textarea submits on IME composition Enter

1 participant

@mahirhir