Image nested In Text with lineHeight specified overflows container
还没有人认领这个 Issue。
- 主要语言
- C++
- 星标
- 127k
- 派生
- 25.3k
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 4
描述
Description
An <Image> nested within <Text> with a lineHeight specified causes the image to overflow the parent container.
Workarounds attempted:
- Specifying a fixed height on the image
- Wrapping the image in a
<View>with a fixedheightand/orlineHeight - Wrapping the Image in another
<Text>with a fixedheightand/orlineHeight - Wrapping the image in another
<Text>with lineHeight set toundefinedornull
Expected behaviour:
To be able to nest images in Text with a non-default lineHeight.
(Please let me know if any more details are required for this issue. Thanks!)
Steps to reproduce
Please see expo snack.
Code below:
export default function App() {
return (
<View style={styles.container}>
<View style={styles.box}>
<Text style={styles.text}>
Hello
<Image style={styles.image} source={require('./assets/snack-icon.png')} />
</Text>
</View>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
backgroundColor: '#ecf0f1',
padding: 8,
},
box: {
backgroundColor: 'red',
},
text: {
backgroundColor: 'blue',
// lineHeight: 20,
},
image: {
height: 300,
}
});
React Native Version
0.76.0
Affected Platforms
Runtime - iOS, Runtime - Android
Output of npx react-native info
Please see expo snack.
Stacktrace or Logs
N/A
Reproducer
https://snack.expo.dev/@tomkelsey/image-nested-in-text-lineheight-bug
Alternative reproducer:
https://github.com/OzymandiasTheGreat/rn-view-in-text-bug
Screenshots and Videos
Without lineHeight specified:
With lineHeight specified:
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
先从所提供的 Expo Snack 和替代复现环境中的 App 组件与样式开始,然后比较 iOS 和 Android 上未指定 lineHeight 与指定非默认 lineHeight 时的布局。当嵌套在 Text 中的 Image 在两个平台上都保持在父容器内时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, react-native
- 领域
- mobile
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100