fix(ui): guard custom-answer textarea against IME composition Enter (#20850) - #33727
Closed
mahirhir wants to merge 1 commit into
Closed
fix(ui): guard custom-answer textarea against IME composition Enter (#20850)#33727mahirhir wants to merge 1 commit into
mahirhir wants to merge 1 commit into
Conversation
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
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #20850
Type of change
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 whileevent.isComposingis true, plus thekeyCode === 229fallback 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 thekeyCode === 229fallback — 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.Screenshots / recordings
No visual change — this is keydown behavior, covered by the unit tests above rather than a screenshot.
Checklist