fix: improve language detection for IME composition (Chinese input)#1230
Open
p0ssword wants to merge 1 commit into
Open
fix: improve language detection for IME composition (Chinese input)#1230p0ssword wants to merge 1 commit into
p0ssword wants to merge 1 commit into
Conversation
- Add compositionstart/compositionend event handlers to track IME composition state - Prevent language detection while user is composing text with IME - Use isComposingRef flag to skip detection during IME composition - Perform language detection immediately after composition completes - Fix issue where Chinese input was incorrectly detected as English
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.
Problem
When typing Chinese characters using an IME (Input Method Editor), the language detection was frequently incorrect, often detecting the text as English instead of Chinese.
Root Cause
The language detection was triggered during the IME composition process (while the user is still typing), leading to detection of incomplete text fragments.
Solution
Implemented IME composition event handling to prevent language detection during composition:
compositionstartandcompositionendevent handlersisComposingRefflagChanges
SourceArea/index.jsxto add composition event handlerschangeSourceTextfunction to check composition stateTesting
✓ Tested with Chinese IME input
✓ Language is now correctly detected as Chinese
✓ Works with dynamic translation feature