react / react/react-native

Bug: TextInput with multiline and lineHeight has height issue when controlled

オープン
#46,207 コメント 6 件 リアクション 5 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Component: TextInput Issue: Author Provided Repro Newer Patch Available
主要言語
C++
スター
127k
フォーク
25.3k
平均マージ
1日 23時間
マージ済み PR(30日)
4

説明

Description

I'm experiencing a bug with the TextInput component when using it as a controlled component with both multiline and lineHeight properties. This issue occurs only on iOS; it does not occur on Android.

Expected Behavior:

The TextInput should adjust its height according to the content without any unexpected changes.

Actual Behavior:

On iOS, when the TextInput is controlled, the height of the TextInput increases unexpectedly as the number of lines increases.
This issue does not occur when the TextInput is uncontrolled.

Steps to reproduce
  1. Create a TextInput component with the following properties:
    • multiline={true}
    • lineHeight set to a specific value (e.g., 60)
    • Controlled by a state variable (value and onChangeText props).
  2. Type text into the TextInput to increase the number of lines.
React Native Version

0.75.2
I have confirmed that this issue does not occur in version 0.73.2.

Affected Platforms

Runtime - iOS

Output of npx react-native info
System:
  OS: macOS 14.4
  CPU: (8) arm64 Apple M1 Pro
  Memory: 236.09 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.12.2
    path: ~/.nvm/versions/node/v20.12.2/bin/node
  Yarn:
    version: 1.22.22
    path: ~/.nvm/versions/node/v20.12.2/bin/yarn
  npm:
    version: 10.5.0
    path: ~/.nvm/versions/node/v20.12.2/bin/npm
  Watchman:
    version: 2024.07.15.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.4
      - iOS 17.4
      - macOS 14.4
      - tvOS 17.4
      - visionOS 1.1
      - watchOS 10.4
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.18034.62.2411.12071903
  Xcode:
    version: 15.3/15E204a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.12
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react: Not Found
  react-native: Not Found
  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
-
Reproducer

https://snack.expo.dev/@holyunwoo/eager-indigo-cereal?platform=ios

Screenshots and Videos
Uncontrolled

https://github.com/user-attachments/assets/7c359007-c157-4e68-814d-45a60c97239d

Controlled

https://github.com/user-attachments/assets/1cf5a2e8-0cc7-4a81-bb6d-4b9ae0741e1b

SCR-20240825-qgyj

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

リンクされた Snack の再現コードと TextInput のエントリポイントから始め、iOS で multiline、lineHeight、controlled な value/onChangeText の動作を確認します。React Native 0.75.2 と 0.73.2 で高さの変化を比較します。完了の条件は、行数が増えても controlled と uncontrolled の入力が期待どおり内容に基づく高さを維持し、Android の動作に影響を与えないことです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
react-native
領域
mobile
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。