Skip to content

Uncontrolled multiline TextInput doesn't auto-grow #54570

Open

Description

@vova-sqds

Description

Uncontrolled multiline TextInput doesn't grow in size when its content spans multiple lines while typing.

Minimum reproducible code:

<View
      style={{ height: 500, justifyContent: "center", padding: 20, width: 180 }}
    >
      <TextInput
        multiline
        placeholder="height increases"
        defaultValue="super long text that will cause the height to span multiple lines"
        enablesReturnKeyAutomatically={true}
        returnKeyType="go"
        style={{
          borderWidth: 1,
          fontSize: 13,
          padding: 4,

          // multilineExpandable
          height: "auto",
          maxHeight: 100,
        }}
      />
</View>
ScreenRecording_11-17-2025.21-53-10_1.mov

If the defaultValue is long enough to take multiple lines, then it does auto-grow/shrink on subsequent edits

Image
ScreenRecording_11-17-2025.22-00-48_1.MP4

Steps to reproduce

  1. paste the reproduction code snippet to an empty screen
  2. try typing into the input until the content starts wrapping

React Native Version

0.81.4

Affected Platforms

Runtime - iOS

Output of npx @react-native-community/cli info

System:
  OS: macOS 26.1
  CPU: (10) arm64 Apple M4
  Memory: 1.16 GB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 24.8.0
    path: ~/.nvm/versions/node/v24.8.0/bin/node
  Yarn:
    version: 4.9.2
    path: ~/.n/bin/yarn
  npm:
    version: 11.6.0
    path: ~/.nvm/versions/node/v24.8.0/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 25.1
      - iOS 26.1
      - macOS 26.1
      - tvOS 26.1
      - visionOS 26.1
      - watchOS 26.1
  Android SDK: Not Found
IDEs:
  Android Studio: Not Found
  Xcode:
    version: 26.1.1/17B100
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: javac 25
    path: ~/.sdkman/candidates/java/current/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 19.1.0
    wanted: "*"
  react-native:
    installed: 0.81.4
    wanted: "*"
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Stacktrace or Logs

-

MANDATORY Reproducer

https://snack.expo.dev/@vova.sqds/uncontrolled-multiline-textinput-doesnt-auto-grow

Screenshots and Videos

No response

Activity

  1. valentinchelle commented on Nov 22, 2025

    @valentinchelle

    Following.

  2. Thotaharshavardhani commented on Nov 24, 2025

    @Thotaharshavardhani

    I was able to reproduce this issue, this issue happens only on iOS with the New Architecture (Fabric). The TextInput auto-expands correctly for the initial multi-line defaultValue, but after clearing and typing again it stops resizing. Works fine on Android and on iOS Legacy Architecture.

  3. Nedi11 commented on Nov 25, 2025

    @Nedi11

    +1, is there any workaround in the meantime, besides making it controlled

  4. vova-sqds commented on Nov 27, 2025

    @vova-sqds
    Author

    +1, is there any workaround in the meantime, besides making it controlled

    haven't found any :|

  5. sintylapse commented on Jan 23, 2026

    @sintylapse

    +1, is there any workaround in the meantime, besides making it controlled

    The workaround is to set defaultValue as multiline initially and then set text to the true default value on render

    useEffect(() => {
      executeOnce(() => {
        inputRef.current?.setNativeProps({ text: defaultValue });
      })
    }, [defaultValue])
    
    <TextInput
      defaultValue={`
              
      `}
    
  6. tmw102 commented on Jan 24, 2026

    @tmw102

    It's very hacky but I've had success creating a hidden View absolutely positioned exactly under the TextInput with a Text element inside it set to the value and style of the TextInput.

    Using the View's onLayoutChange() I take the height of the View and animate the TextInput to that height.

    @sintylapse I couldn't get your solution working in my code.

  7. victoriomolina commented on May 1, 2026

    @victoriomolina

    +1

  8. iqorlobanov commented on May 14, 2026

    @iqorlobanov

    +1

  9. TheBlueFriend commented on Aug 31, 2026

    @TheBlueFriend

    I primarily use React Native to build websites. There is the same issue on web. Works fine on Android.

  10. cadumillet commented on Oct 25, 2026

    @cadumillet

    We hit this too and traced the cause on iOS / Fabric. It reproduces in a blank npx @react-native-community/cli init --version 0.86.3 app (New Architecture on, prebuilt core, Xcode 27.1, iOS 26.5 simulator), and the same code is unchanged in 0.88.0 and on main.

    Minimal repro: an uncontrolled <TextInput multiline placeholder="Title" style={{ fontSize: 22, lineHeight: 28, padding: 8 }} /> that mounts empty. Type a sentence longer than one line: the field stays one line high, the text scrolls and the first line is cut off. The same field with defaultValue="a" grows as expected.

    Root cause (ReactCommon/react/renderer/components/textinput/BaseTextInputShadowNode.h, line numbers as of 0.86.3):

    1. updateStateIfNeeded (L154) returns early when the React-tree attributed string is content-equal to the state's reactTreeAttributedString (L160). For a field that mounts empty, both have zero fragments, so isContentEqual is true and the state is never written. The state keeps its default reactTreeAttributedString, whose base TextAttributes::fontSizeMultiplier is NaN (TextAttributes.h L49, quiet_NaN()).
    2. While the user types, RCTTextInputComponentView _updateState updates only attributedStringBox. reactTreeAttributedString keeps the NaN multiplier.
    3. attributedStringBoxToMeasure (L199) sets meaningfulState (L201) only if the state's reactTreeAttributedString.getBaseTextAttributes().fontSizeMultiplier == layoutContext.fontSizeMultiplier. NaN never compares equal, so meaningfulState is always false.
    4. With meaningfulState false, the node measures getAttributedString(layoutContext) from props.text. For an uncontrolled input that stays empty, so it falls back to getPlaceholderAttributedString (L217) and measures the placeholder: one line.

    A field that mounts with text gets past step 1 (the strings differ), so its state gets a real multiplier and meaningfulState becomes true after the first native update. That matches the reports above: a long defaultValue works, and an empty start does not.

    A possible fix: write the state when the base text attributes differ even if the content is equal, or treat a NaN multiplier in the state as "not set" so it does not block meaningfulState.

    @janicduplessis, #56291 looks related (stale attributedStringBox when children change). From the description I couldn't tell whether it also covers this NaN-multiplier path for a plain uncontrolled input that mounts empty. It may be worth a check.

    Workaround we use: an invisible Text with the field's exact font, line height, padding and font scaling, holding the current text (from onChangeText, or the placeholder when empty). The TextInput is laid absolutely over it, so the copy sizes the container. The copy is hidden from accessibility (aria-hidden, importantForAccessibility="no-hide-descendants") and has pointerEvents="none". Making the input controlled also avoids it, but brings back the stale-eventCount write-back problem while typing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions