fix: send button not switching from voice button during IME composition - #40148
fix: send button not switching from voice button during IME composition#40148FuanSol wants to merge 2 commits into
Conversation
…on (CJK input) Fixes NousResearch#40146 The hasComposerPayload variable only checked the draft state, but during IME composition, handleEditorInput returns early and doesn't update draft. This caused the voice button to remain visible during CJK input. Changes: - Add composingVersion state to force re-renders on composition events - Check editor content directly in hasComposerPayload - Trigger re-render on compositionStart and compositionEnd
Detailed Explanation of the Flickering IssueThe flickering occurs during the IME composition lifecycle: Timeline of the Bug
Visual RepresentationWhy the Fix WorksBy checking |
When IME composition ends, the draft state was not being updated from the editor content. This caused the send button to show correctly but the message wouldn't send when pressing Enter or clicking send. Now we update draftRef and aui composer state when composition ends.
|
Sorry, after fixing this issue, another problem was discovered: when entering non-English characters, they cannot be sent directly. You must add a number or an English character after them for the input to be sent. I was worried that this might be caused by the change I made, so I closed the PR. However, after trying, I can't fix it in a short time. So, after some thought, I decided to raise the issue and reopen the PR. |
|
Thanks for the careful IME lifecycle analysis. This is now implemented on current
Automated hermes-sweeper review. |
Description
Fixes #40146
The
hasComposerPayloadvariable only checked thedraftstate, but during IME composition,handleEditorInputreturns early and doesn't updatedraft. This caused the voice button to remain visible during CJK input.Changes
composingVersionstate - A dummy counter to force React re-renders when composition state changeshasComposerPayloadnow also checks if the editor has content viacomposerPlainText(editorRef.current)onCompositionStartandonCompositionEndnow callsetComposingVersion(v => v + 1)to force a re-renderTesting
Code Changes