Wrong safe area in presence of absolute-positioned view
See original GitHub issueBug report
Summary
As you can see from the screenshot, the safe area is computed wrongly when a view with position: absolute
is placed near the view pager.
Environment info
react-native info
output:
System:
OS: macOS 10.15.4
CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Memory: 21.57 MB / 8.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.14.1 - ~/.nvm/versions/node/v12.14.1/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.13.7 - ~/.nvm/versions/node/v12.14.1/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.8.4 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 13.5, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK: Not Found
IDEs:
Android Studio: 4.0 AI-193.6911.18.40.6514223
Xcode: 11.5/11E608c - /usr/bin/xcodebuild
Languages:
Java: 9.0.4 - /usr/bin/javac
Python: 3.7.2 - /Users/federico/miniconda3/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.9.0 => 16.9.0
react-native: 0.62.2 => 0.62.2
npmGlobalPackages:
*react-native*: Not Found
Library version: “^4.0.0”,
Steps to reproduce
const ViewPagerScreen = (props) => {
const pages = [
<View>
<View style={{flex: 1, backgroundColor: 'green'}}>
<SafeAreaView style={{flex: 1}}>
<Text style={{fontSize: 24}}>Title text</Text>
</SafeAreaView>
</View>
</View>
];
return (
<>
<View style={{...StyleSheet.absoluteFillObject, backgroundColor: 'black'}} />
<ViewPager initialPage={0} showPageIndicator={false}
orientation="horizontal"
style={{flex: 1}}
>
{pages}
</ViewPager>
// if you remove this problematic footer view, all works as expected
<SafeAreaView>
<View style={{position: "absolute", bottom: 0, left: 0, right: 0}}>
<View style={styles.footer}>
<View style={styles.footerSubContLeft}>
<Button title="Home" color='black' onPress={() => {}} />
</View>
<View style={styles.footerSubContRight}>
<Button title="Next" color='black' onPress={() => {}} />
</View>
</View>
</View>
</SafeAreaView>
</>
);
}
const styles = StyleSheet.create({
footer: {
flexDirection: "row",
marginBottom: 20,
backgroundColor: 'yellow'
},
footerSubContLeft: {
flex: 1,
alignItems: "flex-start",
},
footerSubContRight: {
flex: 1,
alignItems: "flex-end",
}
});
Describe what you expected to happen:
The text view should be inside the SafeArea. If I remove the yellow view (footer), this is respected.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Wrong safe area in presence of absolute-positioned view #185
As you can see from the screenshot, the safe area is computed wrongly when a view with position: absolute is placed near the...
Read more >View with absolute position in SafeAreaView in React Native
Unfortunately, the absolute position seems to be relative to the full screen instead of its parent view (the SafeAreaView ). Is there a...
Read more >Positioning content relative to the safe area - Apple Developer
Safe areas help you place your views within the visible portion of the overall interface. UIKit-defined view controllers may position special views on...
Read more >Absolute positioning for SwiftUI views - a free Hacking with iOS
SwiftUI gives us two ways of positioning views: absolute ... Now you'll see the text is in the same location, but the whole...
Read more >Is it a bad design decision to use position: absolute ... - Quora
If you mean absolutely positioning some elements within the page, then be sure to specify the parent as relatively positioned. This will ensure...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No, that happens also after having removed childrenWithOverriddenStyles 😕
I still have this issue on iOS in 2022. Was there any solution?