zIndex is broken across ScrollViews
See original GitHub issue🐛 Bug Report
zIndex is broken when you have a ScrollView between your two different zIndexes. For example, given code like
render() {
return <View style={styles.background}>
<View style={styles.redBox}></View>
<View>
<View style={styles.greenBox}></View>
</View>
</View>
}
let styles = StyleSheet.create({
background: {
backgroundColor: "blue",
height: "100%"
},
greenBox: {
backgroundColor: "green",
width: 100,
height: 100,
zIndex: 2
},
redBox: {
height: 300,
width: 300,
backgroundColor: "red",
position: "absolute",
top: 0,
left: 0,
zIndex: 1
},
});
you get a view that makes sense, blue background, then red box, then green box on top.
However, if you just switch the container of the green box to a ScrollView, the zIndex breaks:
<View style={styles.background}>
<View style={styles.redBox}></View>
<ScrollView>
<View style={styles.greenBox}></View>
</ScrollView>
</View>
Expected Behavior
Components inside of a ScrollView should still respect zIndex.
Code Example
import React, { Component } from 'react';
import {
View,
ScrollView,
StyleSheet,
} from 'react-native';
export default class App extends Component {
render() {
return (
<View style={styles.background}>
<View style={styles.redBox}></View>
<ScrollView>
<View style={styles.greenBox}></View>
</ScrollView>
</View>
);
}
}
let styles = StyleSheet.create({
background: {
backgroundColor: "blue",
height: "100%"
},
greenBox: {
backgroundColor: "green",
width: 100,
height: 100,
zIndex: 2
},
redBox: {
height: 300,
width: 300,
backgroundColor: "red",
position: "absolute",
top: 0,
left: 0,
zIndex: 1
},
});
Environment
Environment: OS: Windows 10 Node: 9.3.0 Yarn: 1.3.2 npm: 4.6.1 Watchman: Not Found Xcode: N/A Android Studio: Version 3.2.0.0 AI-181.5540.7.32.5056338
Packages: (wanted => installed) react: 16.3.2 => 16.3.2 react-native: ^0.55.4 => 0.55.4
It’s worth noting that on iOS not even the working example I give here works, it doesn’t show the green box above the red one ever.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:20
Top Results From Across the Web
z-index issue in react-native - Stack Overflow
I changed top to Bottom but the components which were on the top of scrollview are not getting overlapped. As I am new...
Read more >Creating performant scrollable stacks - Apple Developer
Creating performant scrollable stacks. Display large numbers of repeated views efficiently with scroll views, stack views, and lazy stacks.
Read more >ScrollView - React Native
Component that wraps platform ScrollView while providing integration with touch locking "responder" system.
Read more >scroll-padding-top - CSS: Cascading Style Sheets | MDN
... will-change · word-break · word-spacing · writing-mode · z-index ... counter() · counters() · cross-fade(); Experimental element() ...
Read more >Version 7.1, What's New Webix Docs
... check modality and correct window's zIndex; the incorrect rendering Radar Chart with a single ... scrollTo in the Scrollview breaks scrolling on...
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
RN 0.62.2 also having this issue , Any solution for this issue?
@fabriziobertoglio1987 Hey, you tested it in only one scrollview. I mean drag/drop between two scrollviews.