react / react/react-native

Uncontrolled multiline TextInput doesn't auto-grow

Đang mở
#54,570 9 bình luận 23 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Component: TextInput Issue: Author Provided Repro Needs: React Native Team Attention
Ngôn ngữ chính
C++
Star
127k
Fork
25.3k
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
4

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách chạy trình tái hiện Expo Snack bắt buộc và xác nhận hành vi của TextInput multiline không được kiểm soát trên iOS. Sau đó, truy vết triển khai TextInput multiline của React Native và đường đi trên iOS; được xem là hoàn tất khi ô nhập liệu mở rộng và thu nhỏ trong khi gõ với một defaultValue dài, tuân theo maxHeight và có kiểm thử hồi quy.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
react-native, typescript
Lĩnh vực
mobile
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
62/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.