react / react/react-native

Baseline alignment does not respect numberOfLines text property

未关闭
#35,276 3 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Needs: Triage :mag: Never gets stale
主要语言
C++
星标
127k
派生
25.3k
平均合并
1 天 23 小时
30 天内合并 PR
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. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

使用链接的 Snack,通过在一个行方向的 View 中放置 Text,并将 alignItems 设置为 baseline、将 numberOfLines 设置为 1,复现仅 Android 上出现的行为。跟踪 Android 对 Text 布局和基线对齐的处理,然后验证截断后容器的高度为一行,同时不改变对未受约束文本的预期行为。

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

评估

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

把新 issue 发到你的邮箱

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