react / react/react-native

Different TextInput behavior with flex-basis:0

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

还没有人认领这个 Issue。

Component: TextInput Issue: Author Provided Repro Needs: Triage :mag:
主要语言
C++
星标
127k
派生
25.3k
平均合并
1 天 23 小时
30 天内合并 PR
4

描述

Description

Android and IOS exhibit different behaviors in the following scenario: a textInput with a thick border and flex:1, within a view with flex:1.

On Android, the border is not taken into account to determine the size to allot to the textInput.

Possibly related to https://github.com/facebook/react-native/issues/38518

React Native Version

0.72.3

Output of npx react-native info

System:
OS: Windows 10 10.0.19045
CPU: (32) x64 AMD Ryzen Threadripper PRO 3955WX 16-Cores
Memory: 92.13 GB / 127.86 GB
Binaries:
Node:
version: 20.4.0
path: C:\Program Files\nodejs\node.EXE
Yarn: Not Found
npm:
version: 9.8.0
path: C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
Windows SDK: Not Found
IDEs:
Android Studio: AI-222.4459.24.2221.10121639
Visual Studio:
- 17.6.33723.286 (Visual Studio Community 2022)
Languages:
Java: 1.8.0_372
Ruby: Not Found
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.72.3
wanted: 0.72.3
react-native-windows: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: Not found
newArchEnabled: Not found

Steps to reproduce

In the example below, the text is below the textInput's border on web and iOS, but above the border on Android, leaving almost no room for the textInput's background.

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

https://snack.expo.dev/ANgohiA9k?platform=android

        <View style={{maxHeight:1000, minHeight:50, backgroundColor:'green'}}>
          <View style={{backgroundColor: 'yellow',
              flex:1,
              height:200,
              marginTop: 20,
              }}>
            <TextInput style={{borderTopWidth: 20, borderColor: 'red', backgroundColor:'blue', height:100, flex:1, padding:0 }}
              editable
              multiline
              value="bla bla bla 2"/>
          </View>
        </View>

贡献指南

打开贡献指南

从这里开始

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

调研方向

从 issue 中链接的 Snack 复现开始,并在 Android、iOS 和 web 上运行。比较所提供的嵌套 View 示例中的 TextInput 布局,尤其关注 20px 的顶部边框、使用 flex:1 的尺寸设置以及多行文本的位置。当各平台一致地处理该边框,并且文本和背景以等效的间距渲染时,即表示完成。

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

评估

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

把新 issue 发到你的邮箱

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