Text component moves child element to left when using RTL in system
还没有人认领这个 Issue。
- 主要语言
- C++
- 星标
- 127k
- 派生
- 25.3k
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 4
描述
Description
If the phone has the RTL (Hebrew) language installed, then the Text component behaves incomprehensibly. The child element moves to the left. This bug does not occur on all devices. In the emulator, Galaxy Tab S6, web or in expo go, everything is displayed well. I noticed this bug on the Galaxy A9. If you change the system language to LTR, then everything is fine and the shift disappears.
React components should be able to be placed anywhere in the application. In my case, I wanted to place a View in a Link from @react-navigation/native and noticed this bug. But this only applies to View component
my code:
import React from 'react';
import {SafeAreaView, Text, View} from 'react-native';
function App(): React.JSX.Element {
return (
<SafeAreaView>
<View
style={{
backgroundColor: 'black',
paddingVertical: 10,
paddingHorizontal: 50,
}}>
<Text style={{backgroundColor: 'red', paddingVertical: 5}}>
<View
style={{
backgroundColor: 'yellow',
paddingVertical: 5,
width: '100%',
}}>
<Text style={{backgroundColor: 'green'}}>
{'\u05E9\u05DC\u05D5\u05DD'}
</Text>
</View>
</Text>
</View>
</SafeAreaView>
);
}
export default App;
Steps to reproduce
- Set language on mobile device Hebrew
- Install app to device
- Look at the block offset
React Native Version
0.76.5
Affected Platforms
Runtime - Android, Build - Linux
Output of npx react-native info
info Fetching system and libraries information...
System:
OS: Linux 6.12 Arch Linux
CPU: (12) x64 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
Memory: 16.67 GB / 31.26 GB
Shell:
version: "5.9"
path: /usr/bin/zsh
Binaries:
Node:
version: 20.10.0
path: ~/.nvm/versions/node/v20.10.0/bin/node
Yarn:
version: 1.22.22
path: /usr/bin/yarn
npm:
version: 10.9.2
path: ~/.nvm/versions/node/v20.10.0/bin/npm
Watchman: Not Found
SDKs:
Android SDK:
API Levels:
- "30"
- "34"
- "35"
Build Tools:
- 30.0.2
- 34.0.0
- 35.0.0
System Images:
- android-35 | Google Play Intel x86_64 Atom
Android NDK: Not Found
IDEs:
Android Studio: AI-242.23339.11.2421.12700392
Languages:
Java:
version: javac 23
path: /usr/bin/javac
Ruby: Not Found
npmPackages:
"@react-native-community/cli":
installed: 15.0.1
wanted: 15.0.1
react:
installed: 18.3.1
wanted: 18.3.1
react-native:
installed: 0.76.5
wanted: 0.76.5
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: Not found
newArchEnabled: false
Stacktrace or Logs
not have error in logs
Reproducer
https://github.com/whiskeycola/test-react-native-text
Screenshots and Videos
This is what I got as a result:
Expected behavior: the child element must fit within the Text horizontally.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先,在使用希伯来语 RTL 的 Android 设备上运行链接的复现程序和提供的嵌套 Text/View 示例,尤其关注 Galaxy A9 的情况。将子 View 的放置位置与 LTR 及其他环境进行比较,然后跟踪 Android Text 的布局行为;当子 View 在报告的 RTL 条件下仍然水平位于 Text 内时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- android, react-native, typescript
- 领域
- frontend, mobile
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100