react / react/react-native

Uncontrolled multiline TextInput doesn't auto-grow

未关闭
#54,570 9 条评论 23 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Component: TextInput Issue: Author Provided Repro Needs: React Native Team Attention
主要语言
C++
星标
127k
派生
25.3k
平均合并
1 天 23 小时
30 天内合并 PR
4

描述

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>

https://github.com/user-attachments/assets/e898cc86-822d-4041-878b-b5f8ae3e3653

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

Image

https://github.com/user-attachments/assets/cf9ddb1b-450c-463c-9876-a0bf90274d27

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先运行必需的 Expo Snack 复现程序,并确认 iOS 上非受控 multiline TextInput 的行为。然后追踪 React Native multiline TextInput 的实现及其 iOS 路径;完成的标准是:使用较长的 defaultValue 进行输入时,输入框会随输入而增大和缩小,遵守 maxHeight,并且具有回归测试覆盖。

由索引模型根据 Issue 内容生成。

评估

技术栈
react-native, typescript
领域
mobile
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
活跃
描述清晰度
基本清楚
新手友好度
62/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。