Using absolute positioning, when the parent element has padding, the width height of the current element is incorrectly laid out using a percentage layout
未关闭
还没有人认领这个 Issue。
Issue: Author Provided Repro
- 主要语言
- C++
- 星标
- 127k
- 派生
- 25.3k
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 4
描述
Description
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
*/
import React from 'react';
import {
SafeAreaView,
ScrollView,
StatusBar,
useColorScheme,
View,
} from 'react-native';
function App(): React.JSX.Element {
const isDarkMode = useColorScheme() === 'dark';
const backgroundStyle = {
backgroundColor: '#eee',
};
return (
<SafeAreaView style={backgroundStyle}>
<StatusBar
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
backgroundColor={backgroundStyle.backgroundColor}
/>
<ScrollView>
<View
style={{
backgroundColor: '#000',
height: 300,
paddingTop: 200,
paddingLeft: 200
}}>
<View style={{
position: 'absolute',
// width height 100%会排除父元素的padding
width: '100%', height: '100%', left: 0, top: 0,
backgroundColor: '#666'
}} />
</View>
</ScrollView>
</SafeAreaView>
);
}
export default App;
In the new architecture, I set the height to 100%, but its height is not equal to the height of the parent container, but will subtract the padding of the parent container
Steps to reproduce
1
React Native Version
0.75.2
Affected Platforms
Runtime - Android, Runtime - iOS
Areas
Fabric - The New Renderer
Output of npx react-native info
System:
OS: macOS 14.5
CPU: (16) x64 Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz
Memory: 35.26 MB / 32.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 18.20.3
path: /private/var/folders/rf/gd60z12164z72bny7z_0d4f80000gn/T/xfs-de932bea/node
Yarn:
version: 3.6.4
path: /private/var/folders/rf/gd60z12164z72bny7z_0d4f80000gn/T/xfs-de932bea/yarn
npm:
version: 10.7.0
path: ~/.nvm/versions/node/v18.20.3/bin/npm
Watchman:
version: 2024.07.15.00
path: /usr/local/bin/watchman
Managers:
CocoaPods:
version: 1.15.2
path: /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.5
- iOS 17.5
- macOS 14.5
- tvOS 17.5
- visionOS 1.2
- watchOS 10.5
Android SDK: Not Found
IDEs:
Android Studio: 2024.1 AI-241.18034.62.2412.12266719
Xcode:
version: 15.4/15F31d
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.11
path: /usr/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.3.1
wanted: 18.3.1
react-native:
installed: 0.75.1
wanted: 0.75.1
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: Not found
newArchEnabled: false
Stacktrace or Logs
empty
Reproducer
https://github.com/ShaoGongBra/rn-test
Screenshots and Videos
No response
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从链接的 rn-test 复现程序和 issue 中的示例 App 组件开始,在 Android 和 iOS 上使用启用 Fabric 的 React Native 0.75.2。使用带 padding 的 parent 复现百分比尺寸行为,然后跟踪 Fabric 布局路径,以确定 child 的尺寸在哪里发生偏差。当绝对定位 child 的 100% 宽度和高度按预期与 parent 容器匹配时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, react-native
- 领域
- mobile
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100