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

Compare styles with the last React snapshot applied to the native multiline input so rejected updates cannot hide later style changes.

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] TextInput ignores attribute-only updates (colour) once the text contains an emoji

1 participant