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.
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 26.
enableFontScaleChangesUpdatingLayouton (the default in 0.88).
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
The component in "Steps to reproduce" is the whole reproducer: a fresh app with that App.tsx shows the bug on any iOS simulator.
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.