From dc4582283bf95de461034bc4dd0a866b46e9b620 Mon Sep 17 00:00:00 2001 From: Jason Zheng <48730262+jasozh@users.noreply.github.com> Date: Tue, 3 Nov 2026 12:59:30 -0800 Subject: [PATCH] Fix uncontrolled multiline TextInput not expanding on iOS (#59417) Summary: Fixes an issue where on iOS, multiline expanding TextInputs do not expand if the input starts off as empty and uncontrolled. ### Root Cause When a multiline TextInput on iOS is provided a `value` and `onChange()` prop, as shown in the [React Native docs](https://reactnative.dev/docs/textinput), the input grows as expected. However, uncontrolled inputs do not grow past the first initial line. On mount, `BaseTextInputShadowNode::updateStateIfNeeded()` writes state only if the text changes, so the first state write is skipped for empty, uncontrolled inputs. As a result, `TextAttributes` keeps the default `fontSizeMultiplier = NaN` which is carried over since iOS copies the previous state for subsequent keystrokes. During measurement, `attributedStringBoxToMeasure()` sees that the current multiplier doesn't match the stored multiplier of NaN and falls back to `props.text` which is empty for uncontrolled inputs. This causes the input to stay one-line tall. ### This PR Modify `BaseTextInputShadowNode::updateStateIfNeeded()` to update the state if base text attributes differ. On mount, the default font multiplier of NaN now differs from the real multiplier, so a state update occurs and the text field grows normally. Changelog: [iOS][Fixed] - Fix multiline TextInput not growing with its content when uncontrolled and initially empty Reviewed By: vzaidman Differential Revision: D127048714 Pull Request resolved: https://github.com/react/react-native/pull/59417 --- .../renderer/components/textinput/BaseTextInputShadowNode.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/react-native/ReactCommon/react/renderer/components/textinput/BaseTextInputShadowNode.h b/packages/react-native/ReactCommon/react/renderer/components/textinput/BaseTextInputShadowNode.h index 394a0c9a3b2..6588afae9ee 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/textinput/BaseTextInputShadowNode.h +++ b/packages/react-native/ReactCommon/react/renderer/components/textinput/BaseTextInputShadowNode.h @@ -157,7 +157,9 @@ class BaseTextInputShadowNode const auto &stateData = BaseShadowNode::getStateData(); const auto &reactTreeAttributedString = getAttributedString(layoutContext); - if (stateData.reactTreeAttributedString.isContentEqual(reactTreeAttributedString)) { + if (stateData.reactTreeAttributedString.isContentEqual(reactTreeAttributedString) && + stateData.reactTreeAttributedString.getBaseTextAttributes() == + reactTreeAttributedString.getBaseTextAttributes()) { return; }