react / react/react-native

[iOS] Ellipsis carries background from trimmed text

未关闭
#37,926 7 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Component: Text Issue: Author Provided Repro Newer Patch Available Platform: iOS Resolution: Fixed
主要语言
C++
星标
127k
派生
25.3k
平均合并
1 天 23 小时
30 天内合并 PR
4

描述

Description

This issue happens on iOS only:

I tried to use nested text which has background, and could be wrapped with an ellipsis. Even the nested text doesn't show, the ellipsis has the background of nested text.

<Text numberOfLines={1} ellipsizeMode={'tail'}>Long text <Text style={{backgroundColor: 'red'}}>Nested text</Text></Text>
React Native Version

0.70.6

Output of npx react-native info

System:
OS: macOS 12.5.1
CPU: (10) arm64 Apple M1 Max
Memory: 548.38 MB / 64.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
Yarn: 1.19.2 - ~/.nix-profile/bin/yarn
npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
Watchman: 4.9.0 - /Users/shidong.lin/.nix-profile/bin/watchman
Managers:
CocoaPods: 1.11.0 - /Users/shidong.lin/.nix-profile/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
Android SDK:
API Levels: 30, 31, 32
Build Tools: 30.0.3
System Images: android-31 | Google Play ARM 64 v8a, android-32 | Google Play ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2022.2 AI-222.4459.24.2221.9862592
Xcode: 14.2/14C18 - /usr/bin/xcodebuild
Languages:
Java: 11.0.11 - /Users/shidong.lin/.nix-profile/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.2.0 => 18.2.0
react-native: https://github.com/react-native/archive/f56cf181afcd364122f94ac8609f9b3c7b0b1afb.tar.gz => 0.70.6
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Steps to reproduce
<Text numberOfLines={1}>Long text <Text style={{backgroundColor: 'red'}}>Nested text</Text></Text>

Just create a long text with colored nested text, check the behavior of ellipsis.

Snack, code example, screenshot, or link to a repository
<Text numberOfLines={1} ellipsizeMode={'tail'}>Long text <Text style={{backgroundColor: 'red'}}>Nested text</Text></Text>

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 iOS 上提供的 React Native 复现开始:一个带红色背景和尾部省略号的单行嵌套 Text。跟踪 iOS 文本渲染和截断路径,以确定为什么被裁剪的嵌套样式会影响省略号。完成标准是省略号不再带有隐藏嵌套文本的背景,同时复现仍能正确截断。

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

评估

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

把新 issue 发到你的邮箱

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