Defer chat composer keyboard handling to active IME composition - #237
Defer chat composer keyboard handling to active IME composition#237aideepmind wants to merge 1 commit into
Conversation
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
|
I have read the CLA Document and I hereby sign the CLA |
|
recheck |
1 similar comment
|
recheck |
|
@kentonv — friendly request: this is my first PR to cloudflare-os, so the |
What does this change?
When a user types Chinese (or other IME-composed text) in the chat composer and presses Enter to confirm a candidate character, the message was being sent instead of inserting the chosen character. The same bug affected the chat-list rename input and the chat-title edit input.
This adds a single early-return guard at the top of three
onKeyDownhandlers inpackages/workshop-frontend/src/ChatInterface.tsx. While the IME is composing, the guard (if (e.nativeEvent.isComposing || e.keyCode === 229) return;) defers to the IME, so Enter confirms a CJK candidate, Backspace edits the IME buffer, and arrow keys move within the IME instead of triggering application shortcuts.Why is this obviously correct and trivially verifiable?
Three identical one-line guards in three known locations. The check is the standard, well-known IME-composition pattern used by antd, Radix, and GitHub Primer.
isComposingis the modern spec-correct flag;keyCode === 229is the legacy fallback for browsers / IMEs that fail to set it.The complete effects are:
<textarea>onKeyDowndefers to the IME while composing. This covers Enter-send, Enter-on-slash-picker, Backspace-on-token, ArrowLeft/Right-on-token, and Escape-on-slash-picker — all of which were at risk of misfiring during composition.<input>onKeyDowndefers to the IME, so Enter no longer prematurely saves the rename while the user is still picking CJK characters.<input>onKeyDowndefers to the IME, with the same effect for chat titles.pnpm types:checkandpnpm lint:checkboth pass on the change.Checklist