react / react/react-native

multiline TextInput does not render value properly with newline characters

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

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

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

説明

Description

Unstyled TextInput in a SafeAreaView has some strange behaviour when it's value prop contains new line characters.
The text seems to clip under the first line break and does not appear before tapping the text input box.

Some considerations:

  • Does not happen for long text that breaks "naturally" (no line breaks)
  • I can't reproduce this using a normal view and not a safe area view
    • Wrapping the text input in a view does not fix the issue as long as there exists a parent SafeAreaView
  • I can't reproduce this in the iOS simulator using Expo Snack (SDK 49.0.0)
  • alignSelf: "flex-start" seems to fix the issue
Steps to reproduce
  1. clone the reproducer repo
  2. install and initialize:
yarn install
cd ios
pod install
  1. run according to docs:
yarn start
yarn run ios
  1. Observe the text clipping after two lines. Tap the text to make the rest of it appear. Reload to make it appear again.
React Native Version

0.73.1

Affected Platforms

Runtime - iOS, Build - MacOS

Output of npx react-native info
System:
  OS: macOS 14.1.1
  CPU: (10) arm64 Apple M1 Pro
  Memory: 3.85 GB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.18.2
    path: ~/.nvm/versions/node/v18.18.2/bin/node
  Yarn:
    version: 1.22.19
    path: ~/.nvm/versions/node/v18.18.2/bin/yarn
  npm:
    version: 9.8.1
    path: ~/.nvm/versions/node/v18.18.2/bin/npm
  Watchman:
    version: 2023.10.09.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.13.0
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.0
      - iOS 17.0
      - macOS 14.0
      - tvOS 17.0
      - watchOS 10.0
  Android SDK: Not Found
IDEs:
  Android Studio: Not Found
  Xcode:
    version: 15.0.1/15A507
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.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: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false
Stacktrace or Logs
No relevant stacktrace
Reproducer

https://github.com/HaakonSvane/TextInputBug

Screenshots and Videos

https://github.com/facebook/react-native/assets/36899138/d0caa3ff-425c-4ee5-bf41-49e4e550736b

(I added red background color to the safe area view to better visualize the element size before and after text appears. There seems to be no apparent change)

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

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

はじめの一歩

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

調査の方向性

まず、記載されている yarn、pod install、iOS コマンドを使って、リンクされている TextInputBug の再現手順を実行します。スタイルが設定されていない複数行の TextInput、改行文字、親の SafeAreaView の間にある iOS の相互作用を、比較対象として alignSelf: "flex-start" を使って調査します。これに依存せず、入力欄をタップする前に完全な値がレンダリングされれば完了です。

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

評価

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

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

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