react / react/react-native

Baseline alignment does not respect numberOfLines text property

オープン
#35,276 コメント 3 件 リアクション 1 件 担当者 0 名 GitHub で見る

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

Needs: Triage :mag: Never gets stale
主要言語
C++
スター
127k
フォーク
25.3k
平均マージ
1日 23時間
マージ済み PR(30日)
4

説明

Description

This issue is Android specific.

Whenever using alignItems: 'baseline' on a container which has a text element in it with numberOfRows specified, if that text does get truncated, then the container will be as large as the (partly invisible) text is.

Version

0.70.5

Output of npx react-native info

System:
OS: macOS 12.5.1
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 168.17 MB / 16.00 GB
Shell: 3.3.1 - /usr/local/bin/fish
Binaries:
Node: 16.14.2 - /usr/local/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 8.5.3 - /usr/local/bin/npm
Watchman: 2022.10.17.00 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.11.3 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 22.1, iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1
Android SDK: Not Found
IDEs:
Android Studio: 2020.3 AI-203.7717.56.2031.7583922
Xcode: 14.1/14B47b - /usr/bin/xcodebuild
Languages:
Java: 11.0.11 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.1.0 => 18.1.0
react-native: 0.70.5 => 0.70.5
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Steps to reproduce

Wrap a Text component with a View component which has flexDirection set to row and alignItems set to baseline. Make sure the text contains enough text to at least be rendered on 2 lines. Add numberOfLines with the value of 1 on that text. Notice that the container is larger than you'd expect. You'd expect it to be only 1 line high.

Snack, code example, screenshot, or link to a repository

https://snack.expo.dev/LNZyYKCWg

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

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

はじめの一歩

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

調査の方向性

リンクされた Snack を使用し、alignItems を baseline に、numberOfLines を 1 に設定した行方向の View 内の Text で、Android 専用の挙動を再現します。Text のレイアウトとベースライン配置を Android がどのように処理するかを追跡し、その後、制約のないテキストで期待される挙動を変更せずに、切り詰め後のコンテナの高さが 1 行分になっていることを確認します。

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

評価

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

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

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