Repository navigation
fix(ios): re-lay out a misplaced first text fragment in RCTUITextView on iOS 27 - #59446
ShinYoung-Kim wants to merge 1 commit into
Conversation
… on iOS 27 On iOS 27, TextKit 2 can leave the first layout fragment of a UITextView pushed down by its own height after an edit that replaces text inside the first paragraph while later paragraphs exist, e.g. Korean syllable recomposition. RCTUITextView is sized with frames, so nothing lays the fragment out again and the whole text stays shifted until the next edit (FB25281535). After each text change, check the first layout fragment and, when it is misplaced, invalidate and re-lay out only that fragment's range. Fixes react#59386
|
Hi @ShinYoung-Kim! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Summary:
Fixes #59386.
On iOS 27, TextKit 2 can leave the first layout fragment of a
UITextViewpushed down by its own height after an edit that replaces text inside the first paragraph while later paragraphs exist. The Korean keyboard does this on every syllable recomposition, so in a multilineTextInputwithscrollEnabled={false}the whole text jumps down by the height of the first paragraph while typing. Reported to Apple as FB25281535.UIKit hides this when the text view is sized with Auto Layout, because re-measuring through
intrinsicContentSizelays the fragment out again.RCTUITextViewis sized with frames, so nothing does that and the text stays shifted until the next edit. A frame-sizedUITextViewin a plain UIKit app behaves the same way.This change checks the first layout fragment after each text change, and when its
origin.yis greater than 0, invalidates and re-lays out only that fragment's range. Invalidating first is required:ensureLayoutForRange:alone does not fix it.sizeThatFits:orintrinsicContentSizealso fixes it, but took 35 ms per keystroke for a 9,204-character text on an iPhone 15 Pro.Changelog:
[IOS] [FIXED] - Fix multiline TextInput text shifting down while typing Korean on iOS 27
Test Plan:
Reproducer: https://github.com/ShinYoung-Kim/rn-ios27-textinput-repro. A UI test types
한글 입력key by key on the iOS Korean keyboard at the end of the first paragraph of첫째 줄\n둘째 줄입니다\n셋째 줄입니다, and the app logs the first layout fragment's frame 0, 16, 100 and 300 ms after each change. 8 of the 14 keystrokes replace the previous syllable.iPhone 15 Pro, iOS 27.0.1, React Native 0.88.0 built from source:
multiline,scrollEnabled={false}multiline,scrollEnabledAlso checked: