So i found this open issue regarding this bug - https://github.com/react-navigation/react-navigation/issues/12511
Although someone offers a solution in the comments it doesnt work for me and after experimenting and inspecting the source code i figured it has to do with the drawer translating it's location.
To fix the unwanted behavior i used:
drawerType: "back"
in the drawer's screenOptions like this:
import { createDrawerNavigator } from '@react-navigation/drawer';
import Index from './index';
import Test from './test';
const Drawer = createDrawerNavigator();
export default function RootLayout() {
return (
<Drawer.Navigator screenOptions={{drawerPosition:'right', drawerType: 'back'}}>
<Drawer.Screen name="index" component={Index} />
<Drawer.Screen name="test" component={Test} />
</Drawer.Navigator>
);
}
This way we avoid changing the drawer's location.. I'll add this info to the issue & hope it will be fixed asap. Hope this helps someone, Goodluck !