React-native-web: z-index stacking context issues

Created on 19 Oct 2017  路  8Comments  路  Source: necolas/react-native-web

In react native every view creates a stacking context but in react native web, it obviously follows the browsers default rules.

I have an issue in my app that I've distilled to a jsbin -> https://jsbin.com/bimoyib/edit?html,css,output

The issue is that container1 should create its own stacking context, and the z-index of every child within that container should have no effect outside of it. So since the blue box is after container1, it should appear above it.

We could fix this issue by making all Views have z-index: 0; by default. This makes all views create a stacking context (see https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context)

  • Browser: All browsers
  • React Native for Web (version): 0.0.130

Most helpful comment

Probably not. The only performance issue I'm aware of with z-index is when z-indices of elements are dynamically changed in a DOM tree. Adding zIndex:0 to every view doesn't seem to be an issue when locally testing Twitter Lite.

All 8 comments

Please can you create a test case using RNW (eg on glitch or snack.expo.io)?

Thanks, good find

Will this incur a large performance hit?

Probably not. The only performance issue I'm aware of with z-index is when z-indices of elements are dynamically changed in a DOM tree. Adding zIndex:0 to every view doesn't seem to be an issue when locally testing Twitter Lite.

With this update. We are unable to unset the z-index because the proptype expects a number.
"Warning: Failed prop type: Invalid prop zIndex of type string supplied to View, expected number."
so can't use initial or unset

@necolas
The contents of the FlatList's ListHeaderComponent and renderItem are obscured by the ListFooterComponent

Can only be enforced by

  <View className="clear-flat-list-z-index" style={Style.wp}>
    <FlatList></FlatList>
  </View>
.clear-flat-list-z-index > div > div > div > div {
    z-index: auto !important;
}

Please open an issue with all the information in the template filled out

Was this page helpful?
0 / 5 - 0 ratings

Related issues

holmesal picture holmesal  路  3Comments

necolas picture necolas  路  3Comments

Mactub07 picture Mactub07  路  3Comments

rohanprabhu picture rohanprabhu  路  3Comments

PaulBGD picture PaulBGD  路  4Comments