Repository navigation
Description
Description
On iOS (New Architecture), a single-line TextInput that has nested <Text> children loses the
styles of those children when the user changes the OS text size while the app runs. The whole
text gets the style of the TextInput itself (color, font family). The styles come back only after
the next edit that makes React re-render the children with different content.
- It happens to single-line inputs only. A
multilineinput with the same children keeps its styles. - Focus does not matter. A blurred input loses its styles too.
- It happens in both directions (smaller to larger and larger to smaller).
- A
<Text>outside an input is not affected. - A live
colororfontSizeprop change on the same input does not lose the nested styles.
Real-world impact: libraries that render custom emoji, mentions or syntax highlight as nested
<Text> spans inside a TextInput (a span with a custom fontFamily) show missing-glyph boxes
until the next edit.
Steps to reproduce
- Run this component on an iOS simulator (New Architecture).
- Open Settings > Accessibility > Display & Text Size > Larger Text and change the size, or run
xcrun simctl ui booted content_size accessibility-large(thenlargeto go back). - Return to the app.
import { TextInput, Text, View } from 'react-native'
export default function App() {
return (
<View style={{ padding: 40, gap: 12 }}>
{/* Loses the red Courier span after a text size change */}
<TextInput style={{ fontSize: 18, borderWidth: 1 }}>
<Text>
plain <Text style={{ color: 'red', fontFamily: 'Courier' }}>word</Text> end
</Text>
</TextInput>
{/* Keeps the span */}
<TextInput multiline style={{ fontSize: 18, borderWidth: 1 }}>
<Text>
plain <Text style={{ color: 'red', fontFamily: 'Courier' }}>word</Text> end
</Text>
</TextInput>
</View>
)
}Expected
After the text size change, "word" is still red and in Courier, at the new size, in both inputs.
Actual
In the single-line input, the whole text is black and in the system font ("plain word end"). The
multiline input is correct.
RNTester on main, iPhone 17 Pro simulator, iOS 26.5. Large, then Accessibility Large, then back to Large:
Environment
- React Native 0.88.1 (New Architecture, prebuilt and from-source React Native core both checked).
mainhas the same code (RCTTextInputComponentView.mm:153-163); there the feature-flag check is gone, so the bug happens unconditionally. The diff below is against 0.88.1. - iOS 26.5 simulator (iPhone 17 Pro). Xcode and SDK versions are in the
cli infooutput below. enableFontScaleChangesUpdatingLayouton (the default in 0.88).
Output of npx @react-native-community/cli info
Run in an Expo SDK 58 app on React Native 0.88.1:
System:
OS: macOS 27.2.1
CPU: (14) arm64 Apple M4 Pro
Memory: 168.50 MB / 24.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 24.22.1
Yarn:
version: 1.22.22
npm:
version: 11.19.1
Watchman:
version: 2025.12.15.00
Managers:
CocoaPods:
version: 1.16.2
SDKs:
iOS SDK:
Platforms:
- DriverKit 27.2
- iOS 27.2
- macOS 27.2
- tvOS 27.2
- visionOS 27.2
- watchOS 27.2
IDEs:
Xcode:
version: 27.2/27B52
path: /usr/bin/xcodebuild
Languages:
Ruby:
version: 3.4.8
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 19.3.0
wanted: 19.3.0
react-native:
installed: 0.88.1
wanted: 0.88.1
react-native-macos: Not Found
iOS:
hermesEnabled: true
newArchEnabled: true
Root cause
RCTTextInputComponentView (React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm):
// :138-150 (0.88.1)
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection
{
[super traitCollectionDidChange:previousTraitCollection];
if (ReactNativeFeatureFlags::enableFontScaleChangesUpdatingLayout() &&
UITraitCollection.currentTraitCollection.preferredContentSizeCategory !=
previousTraitCollection.preferredContentSizeCategory) {
const auto &newTextInputProps = static_cast<const TextInputProps &>(*_props);
_backedTextInputView.defaultTextAttributes =
RCTNSTextAttributesFromTextAttributes(newTextInputProps.getEffectiveTextAttributes(RCTFontSizeMultiplier()));
}
}- The single-line backing view
RCTUITextFieldpasses the dictionary to
-[UITextField setDefaultTextAttributes:](Libraries/Text/TextInput/Singleline/RCTUITextField.mm:88-97).
UIKit appliesdefaultTextAttributesto the entire text of aUITextField, so every per-fragment
attribute of the nested<Text>children is replaced. - The multiline backing view
RCTUITextViewonly setstypingAttributes
(Libraries/Text/TextInput/Multiline/RCTUITextView.mm:130-139), so its text keeps its attributes. - Order, checked with lldb breakpoints on a live change: the new state (with the new font size
multiplier and the correct per-fragment attributes) is mounted first through
updateState:oldState:->_setAttributedString:->-[UITextField setAttributedText:]. Then
UIKit callstraitCollectionDidChange:, which flattens that text. No later state update comes, so
nothing restores the fragments. The_textOf:equals:compare is not involved (the flattened text
has noNSOriginalFont). - A side bug in the same method: the dictionary has no
RCTAttributedStringEventEmitterKey, unlike
updateEventEmitter:(:109-119) andupdateProps:oldProps:(:304-310), so the flattened text
also loses its event emitter.
The prop path does not show the bug: updateProps: also flattens the text through
defaultTextAttributes, but the state update of the same mount transaction comes after it and
re-applies the fragments.
Proposed fix
Keep the event emitter key, and after defaultTextAttributes re-apply the state's attributed string
when the React tree owns the text (it has fragments), the native and JS event counts match, there is
no marked text, and the string is the same (so only attributes change). In the typed-text-only case
(no children) the method keeps today's behaviour: the flatten is what resizes the typed text.
--- a/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm
+++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm
@@ -144,9 +144,32 @@
UITraitCollection.currentTraitCollection.preferredContentSizeCategory !=
previousTraitCollection.preferredContentSizeCategory) {
const auto &newTextInputProps = static_cast<const TextInputProps &>(*_props);
- _backedTextInputView.defaultTextAttributes =
+ NSMutableDictionary<NSAttributedStringKey, id> *defaultAttributes =
RCTNSTextAttributesFromTextAttributes(newTextInputProps.getEffectiveTextAttributes(RCTFontSizeMultiplier()));
+ defaultAttributes[RCTAttributedStringEventEmitterKey] =
+ _backedTextInputView.defaultTextAttributes[RCTAttributedStringEventEmitterKey];
+ _backedTextInputView.defaultTextAttributes = defaultAttributes;
+ // `UITextField` applies `defaultTextAttributes` to its whole text. That drops the attributes of
+ // nested <Text> children (color, font family, ...). Re-apply the attributed string of the state.
+ [self _reapplyStateAttributedString];
+ }
+}
+
+- (void)_reapplyStateAttributedString
+{
+ if (!_state || _backedTextInputView.markedTextRange) {
+ return;
}
+ const auto &data = _state->getData();
+ if (data.reactTreeAttributedString.isEmpty() || _mostRecentEventCount != data.mostRecentEventCount) {
+ return;
+ }
+ NSAttributedString *attributedString = RCTNSAttributedStringFromAttributedStringBox(data.attributedStringBox);
+ if (![attributedString.string isEqualToString:_backedTextInputView.attributedText.string]) {
+ return;
+ }
+ _comingFromJS = YES;
+ [self _setAttributedString:attributedString];
+ _comingFromJS = NO;
}Verified on the iOS 26.5 simulator with React Native built from source (Release):
- Single-line inputs keep the nested styles in both directions, focused and blurred.
- The caret stays where it was (checked at offset 4 of 9), and no
onSelectionChangeevent fires. - A single-line input with typed text only (no children) still resizes, as before the patch.
- Multiline inputs are unchanged.
The same diff as a patch-package file: react-native+0.88.1.patch (paths under
node_modules/react-native/). It has an effect only when React Native core is built from source
(RCT_USE_PREBUILT_RNCORE=0 or ios.buildReactNativeFromSource), not with the prebuilt core.
Workaround (JS, without a patch)
Re-render the children with any TextAttributes change after useWindowDimensions().fontScale
changes, for example flip textDecorationColor: 'transparent' on the wrapper <Text>. The new state
differs from the flattened native text, so _setAttributedString: applies the fragments again.
Reproducer
RNTester Playground reproducer: #60069 (it changes only RNTesterPlayground.js).
The component in "Steps to reproduce" also shows the bug in a fresh app on any iOS simulator.
Related issues
These are about Dynamic Type too, but show a different symptom (stale text layout, not lost nested styles):
- [iOS][Fabric] Changing Dynamic Type while the app is running does not re-lay out text (root not dirtied on a layout-context-only change) #59927: a live Dynamic Type change does not re-lay out text.
- [iOS][Fabric] Runtime Dynamic Type change leaves stale text layout: lines overflow and clip, onTextLayout reports stale widths (0.86) #57512: a live Dynamic Type change leaves a stale text layout (0.86).
Activity
react-native-bot commentedon Nov 15, 2026
Warning
Missing reproducer: We could not detect a reproducible example in your issue report. Reproducers are mandatory and we can accept only one of those as a valid reproducer:
You can read more about about it on our website: How to report a bug.
chocky335 commentedon Nov 17, 2026
Reproducer as requested: #60069 (changes only
RNTesterPlayground.js). Fix with a unit test and before/after screenshots: #60070.chocky335 commentedon Nov 17, 2026
Closing in favor of #60090. It has the same report, filed through the bug form with the reproducer (#60069) from the start.
<Text>styles after a live Dynamic Type (text size) change #60090