Fix IME composition Enter key sending message prematurely#31
Conversation
Manho
left a comment
There was a problem hiding this comment.
Thanks for the fix! I tested it locally with Zhuyin IME and it works correctly — Enter during composition no longer triggers send. 👍
A couple of suggestions before merging:
1. Move the IME guard inside the Enter check
Currently the guard returns early for all keydown events during IME composition. Right now that's fine since we only handle Enter, but it could silently break future keybindings (e.g. Escape). Suggest narrowing the scope:
inputTextarea.addEventListener('keydown', (e) => {
if (e.key === 'Enter' && !e.shiftKey) {
if (isInputComposing || e.isComposing) return;
e.preventDefault();
broadcastMessage(inputTextarea.value);
}
});2. Consider dropping e.keyCode === 229
Our content scripts (e.g. enter-behavior-chatgpt.js, enter-behavior-claude.js) only use event.isComposing for IME detection. keyCode === 229 is a legacy approach and may false-positive on some Android soft keyboards. For consistency, isInputComposing || e.isComposing should be sufficient.
Other than that, looks good — nice clean fix for a real pain point! 🎉
|
Thanks for the review and suggestions — I’ve updated the PR accordingly. What I changed
VerificationRe-tested with Zhuyin IME:
This keeps non-Enter keydown handling unblocked during composition. |
Summary
Fix an issue where pressing
Enterduring IME composition (e.g. Zhuyin/Bopomofo candidate selection) accidentally triggers message send before typing is finished.Root cause
unified-inputkeydown handler sent onEnterwithout checking IME composition state.Changes
multi-panel/multi-panel.jscompositionstart->isInputComposing = truecompositionend->isInputComposing = falseisInputComposing || event.isComposing || event.keyCode === 229EntersendsShift+EnternewlineManual test
Enterto select candidate.Enteragain.