Skip to content

fix(ios): re-lay out a misplaced first text fragment in RCTUITextView on iOS 27 - #59446

Open
ShinYoung-Kim wants to merge 1 commit into
react:mainfrom
ShinYoung-Kim:fix/ios27-textinput-first-fragment-shift
Open

ShinYoung-Kim wants to merge 1 commit into
react:mainfrom
ShinYoung-Kim:fix/ios27-textinput-first-fragment-shift

Conversation

@ShinYoung-Kim

Copy link
Copy Markdown

Summary:

Fixes #59386.

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. The Korean keyboard does this on every syllable recomposition, so in a multiline TextInput with scrollEnabled={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 intrinsicContentSize lays the fragment out again. RCTUITextView is sized with frames, so nothing does that and the text stays shifted until the next edit. A frame-sized UITextView in a plain UIKit app behaves the same way.

This change checks the first layout fragment after each text change, and when its origin.y is greater than 0, invalidates and re-lays out only that fragment's range. Invalidating first is required: ensureLayoutForRange: alone does not fix it.

  • Nothing changes while the first fragment is in place. That was the case for every edit on iOS 18.5 and 26.4, and on iOS 27 for every edit that does not trigger the bug. The check costs about 0.01 ms per change.
  • Re-laying out one fragment costs about 0.25 ms per change and does not depend on the text length. Re-measuring the whole view with sizeThatFits: or intrinsicContentSize also 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:

Input Shifted after 16 / 100 / 300 ms, before after
multiline, scrollEnabled={false} 8 / 8 / 8 0 / 0 / 0
multiline, scrollEnabled 0 / 0 / 0 0 / 0 / 0
Before After

Also checked:

  • Japanese Kana input with marked text, conversion and confirm at the same position: same final text with and without the change, no shift either way.
  • iOS 18.5 device, iOS 26.4 and 18.6 simulators: the first fragment stays at y = 0 after every edit, so the new code returns right after the check.
  • 9,204-character input: fixed, about 0.26 ms per shifted keystroke.

… 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
@meta-cla

meta-cla Bot commented Oct 24, 2026

Copy link
Copy Markdown

Hi @ShinYoung-Kim!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 24, 2026
@meta-cla

meta-cla Bot commented Oct 24, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Oct 24, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS] Multiline TextInput with scrollEnabled={false} shifts its text down while typing Korean on iOS 27

1 participant