Skip to content

Fix iOS multiline TextInput style updates after emoji insertion - #60137

Open
FeliksLv01 wants to merge 2 commits into
react:mainfrom
FeliksLv01:fix/ios-textinput-emoji-attributes
Open

FeliksLv01 wants to merge 2 commits into
react:mainfrom
FeliksLv01:fix/ios-textinput-emoji-attributes

Conversation

@FeliksLv01

@FeliksLv01 FeliksLv01 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

Fixes #60089 for multiline TextInput on iOS Fabric. When UIKit reports a fallback font through NSOriginalFont, the existing plain-text comparison can skip style changes in nested <Text> children.

Stale events. Start with black text (eventCount = 1), send a stale red update (0), then send a valid red update with an underline (1). The stale update is rejected, so UIKit still has black text. Fabric can pass that rejected red state as oldState for the final update. Diffing against it detects only the underline and leaves the text black.

Implementation. For style-only updates, compare the incoming React styles by range against the last React styles applied to the multiline input. Update changed attributes in place on UITextView.textStorage. A successful React write or a native text echo with equivalent styles updates that snapshot. Rejected events and styles deferred by input-method guards leave it intact. Comparing React styles avoids treating UIKit font fallback or React event-emitter metadata as style changes and preserves both selection endpoints.

Changelog:

[IOS] [FIXED] - Apply style-only updates to multiline TextInput on iOS Fabric when the text contains an emoji.

Test Plan:

  • iOS 26.2, RNTesterUnitTests: All four RCTTextInputComponentViewTests passed. The stale-event regression verifies that the rejected update leaves the text black and the next valid update applies both red and the underline. The other tests cover style updates with simulated UIKit font fallback, a native text echo with font fallback, and equivalent styles.
  • iOS 27.2, RNTester: After adding ✅, toggled the color and background of one nested <Text>. The adjacent text stayed blue. A toggle with Hello selected preserved the native selection range [0, 5].
  • System Pinyin keyboard: Toggling the color during composition preserved the candidate list and emitted no extra onChange. After selecting 你好, the candidate appeared in the input and Hello turned red.
  • Reproduction note: The original steps did not reproduce the failure naturally on unpatched RN 0.88.1 in the iOS 26.2 and 27.2 simulators. The regression test supplies NSOriginalFont explicitly to exercise the reported path.
XCTest command
cd packages/rn-tester
xcodebuild test -workspace RNTesterPods.xcworkspace -scheme RNTesterUnitTests \
  -configuration Debug -destination 'platform=iOS Simulator,name=iPhone 17 Pro,OS=26.2' \
  -parallel-testing-enabled NO \
  -only-testing:RNTesterUnitTests/RCTTextInputComponentViewTests \
  CODE_SIGNING_ALLOWED=NO ONLY_ACTIVE_ARCH=NO \
  "LIBRARY_SEARCH_PATHS=\$(inherited) $(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator"

Simulator screenshots

Color toggle with ✅ (controlled reproduction)

In both RNTester builds, tap Add ✅, then Toggle color. The status below the input shows Color red. The test harness supplied NSOriginalFont on ✅ to simulate UIKit font fallback.

Before the fix · text stays black After the fix · text turns red
Before the fix, Hello world and the check mark are visible. The text is black and the status below says Color red. After the fix, Hello world and the check mark are visible. The text is red and the status below says Color red.

Pinyin composition (with the fix)

Toggled while Pinyin candidates are visible After selecting 你好
The candidate list remains visible after the color toggle The input contains 你好 and Hello is red

@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 Nov 19, 2026
@FeliksLv01
FeliksLv01 force-pushed the fix/ios-textinput-emoji-attributes branch from 80f8d15 to 9081787 Compare November 19, 2026 08:17
@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 Nov 19, 2026
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Visual regression

No visual differences at c415ca533d5e.

@cipolleschi

Copy link
Copy Markdown
Contributor

can you rebase on top of master to clear the CI signals?

@FeliksLv01
FeliksLv01 force-pushed the fix/ios-textinput-emoji-attributes branch 2 times, most recently from 928db3d to a2ad2e6 Compare November 25, 2026 01:29
@FeliksLv01

Copy link
Copy Markdown
Contributor Author

Done

@FeliksLv01

Copy link
Copy Markdown
Contributor Author

This PR now conflicts with the latest main. I’m resolving the conflict and will update the branch shortly.

@FeliksLv01
FeliksLv01 force-pushed the fix/ios-textinput-emoji-attributes branch from a2ad2e6 to c40ad76 Compare December 2, 2026 07:01
@FeliksLv01

Copy link
Copy Markdown
Contributor Author

Done

@github-actions github-actions Bot added the Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. label Dec 2, 2026
Compare styles with the last React snapshot applied to the native multiline input so rejected updates cannot hide later style changes.
@FeliksLv01
FeliksLv01 force-pushed the fix/ios-textinput-emoji-attributes branch from c40ad76 to c415ca5 Compare December 2, 2026 11:41

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. Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. 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] TextInput ignores attribute-only updates (colour) once the text contains an emoji

2 participants