Fix iOS TextInput IME composition issues for CJK languages#56082
Draft
kdwkr wants to merge 1 commit intofacebook:mainfrom
Draft
Fix iOS TextInput IME composition issues for CJK languages#56082kdwkr wants to merge 1 commit intofacebook:mainfrom
kdwkr wants to merge 1 commit intofacebook:mainfrom
Conversation
CJK (Chinese/Japanese/Korean) IME composition on Fabric was broken in multiple ways - the composition underline disappeared and composition state was destroyed. This was caused by four independent issues: 1. `updateEventEmitter:` reapplied `defaultTextAttributes` every render, which destroyed the composition underline. Now deferred during active `markedTextRange` and applied after composition ends. 2. `_setAttributedString:` overwrote `attributedText` during state round-trips, resetting `markedTextRange`. Now skipped when `markedTextRange` is active. 3. `textInputShouldChangeText:inRange:` enforced `maxLength` during composition, blocking or truncating intermediate IME input. Now deferred until composition commits, with post-composition truncation. 4. `textInputDidChangeSelection` used `isEqual:` on attributed strings, which always failed during composition due to system underline attributes. Changed to bare text comparison via `isEqualToString:`. These issues only affected the New Architecture (Fabric); Paper was unaffected due to its asynchronous bridge timing. Fixes: facebook#48497 Fixes: facebook#55257 Fixes: facebook#55059
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.
Summary:
CJK (Chinese/Japanese/Korean) IME composition on Fabric is broken — the composition underline disappears and composition state is destroyed during input. This affects Japanese, Chinese, and Korean users on the New Architecture and has been reported as a market-blocking issue.
Root causes and fixes:
updateEventEmitter:reappliesdefaultTextAttributesevery render —RCTWrapEventEmittercreates a newNSDataeach time, failingisEqualToDictionary:, which triggers[super setDefaultTextAttributes:]and destroys the composition underline. Fix: defer during activemarkedTextRange, apply after composition ends intextInputDidChange._setAttributedString:overwrites text during state round-trips —updateState:round-trips call_setAttributedString:which replacesattributedText, resettingmarkedTextRange. Fix: skip whenmarkedTextRangeis active; text syncs viatextInputDidChange→_updateStateafter composition.maxLengthenforcement blocks IME mid-composition —textInputShouldChangeText:inRange:enforcesmaxLengthwithout checkingmarkedTextRange, truncating intermediate CJK input (e.g., Korean ㅎ→하→한). Fix: defermaxLengthduring composition, enforce via post-composition truncation intextInputDidChange.textInputDidChangeSelectiontriggers spurious updates in multiline —isEqual:onNSAttributedStringfails during composition due to system underline attributes, causing unnecessarytextInputDidChangecalls. Fix: use.string isEqualToString:for bare text comparison.Paper (old architecture) is unaffected; these issues are Fabric-only due to synchronous
updateEventEmitter:/updateState:calls.Fixes #48497
Fixes #55257
Fixes #55059
Changelog:
[IOS] [FIXED] - Fix CJK IME composition underline disappearing and composition state being destroyed in Fabric TextInput
Test Plan:
RCTTextInputComponentViewIMETests.mmcovering all 4 fixesclang -fsyntax-onlycompilation<TextInput>on Fabric — composition underline should remain visible and composition should not be interruptedmaxLengthprop works correctly after CJK composition commits<TextInput>does not fire spuriousonChangeevents during CJK composition