software-mansion / react-native-screens

Native navigation primitives for your React Native app.
MIT License
3.01k stars 510 forks source link

On Android, `zIndex` stops being respected once the screen transition animation starts, causing the content to flash #1546

Open SimpleCreations opened 2 years ago

SimpleCreations commented 2 years ago

Description

As the title says. Curiously, the problem only reproduces when using a FlatList and when specifying screenOptions (an empty object is enough). See the code sample.

Screenshots

Notice how the red box disappears right as the back button is pressed.

https://user-images.githubusercontent.com/12449725/181281496-4f00c668-f1f5-4cd7-8ba0-e0dbfee23419.mp4

Steps To Reproduce

See the code sample.

Reproduction

import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
import {NavigationContainer} from '@react-navigation/native';
import {createNativeStackNavigator} from '@react-navigation/native-stack';
import {Button, FlatList, View} from 'react-native';
import React from 'react';

const Stack = createNativeStackNavigator();
const Tab = createBottomTabNavigator();

const Parent = ({navigation}) => (
  <Button title="Press me" onPress={() => navigation.navigate('Child')} />
);

const Child = () => (
  <>
    <View
      style={{
        position: 'absolute',
        zIndex: 1,
        width: '100%',
        height: 200,
        backgroundColor: 'tomato',
      }}
    />
    <FlatList // <-- 🛑 important
      style={{backgroundColor: 'pink'}}
      data={[]}
      renderItem={() => null}
    />
  </>
);

const Tabs = () => (
  <Tab.Navigator initialRouteName="Events">
    <Tab.Screen name="Parent" component={Parent} />
  </Tab.Navigator>
);

const App = () => (
  <NavigationContainer>
    <Stack.Navigator screenOptions={{}}>  // <-- 🛑 important
      <Stack.Screen name="Tabs" component={Tabs} />
      <Stack.Screen name="Child" component={Child} />
    </Stack.Navigator>
  </NavigationContainer>
);

export default App;

Platform

Architecture

Workflow

Package versions

  {
    "@react-navigation/bottom-tabs": "^6.3.2",
    "@react-navigation/native": "^6.0.11",
    "@react-navigation/native-stack": "^6.7.0",
    "react": "18.0.0",
    "react-native": "0.69.3",
    "react-native-safe-area-context": "^4.3.1",
    "react-native-screens": "^3.15.0"
  }
tominou commented 2 years ago

Same here (happens with react-navigation using react-native-screens)

ugurdalkiran commented 1 year ago

https://github.com/react-navigation/react-navigation/issues/10875

Could it be the same problem as here?

batuhansahan commented 1 year ago

I can confirm this happen on IOS too when using navigation.goBack with button, zIndex is not respected.

robgraeber commented 1 year ago

Doesn't happen on ios, but happens on android with native stack navigator for me.

LuisMesquita commented 1 year ago

Same here

rubewijk commented 10 months ago

Pcpkomputer commented 8 months ago

MateoParodi commented 1 month ago