Skip to content

Fix uncontrolled multiline TextInput not expanding on iOS - #59417

Open
jasozh wants to merge 2 commits into
react:mainfrom
jasozh:export-D127048714
Open

jasozh wants to merge 2 commits into
react:mainfrom
jasozh:export-D127048714

Conversation

@jasozh

@jasozh jasozh commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

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, 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

Differential Revision: D127048714

Summary:

Add a new RNTester example in TextInputSharedExamples to reproduce iOS and Android issues with auto-expanding multiline text fields. There is already an existing example, but an empty, uncontrolled variant is needed to reproduce certain issues. An existing iOS-only auto-expanding example is removed as well since it duplicates functionality.

Changelog: [Internal]

Differential Revision: D127048669
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

Differential Revision: D127048714
@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 Oct 23, 2026
@meta-codesync

meta-codesync Bot commented Oct 23, 2026

Copy link
Copy Markdown

@jasozh has exported this pull request. If you are a Meta employee, you can view the originating Diff in D127048714.

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-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant