-
-
Notifications
You must be signed in to change notification settings - Fork 514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Header Height jumps with nested navigators #619
Comments
Looks like it is the same issue as #564. Am I right? |
Just tested this, and the issue still happens regardless of the |
There seem to be some layout issues when having a |
I'm using large and blurred headers from native-stack |
@ArekChr It is not a solution to the bug, but a workaround, and I know it cannot be applied in many cases. |
@WoLewicki Any update? I have same issue. I just noticed that this is only happens if stack has animation. simplified test: https://snack.expo.io/KrD6WIJ2l (looks like iOS only) |
@burakgormek @ArekChr @dotconnor can you check if #1025 fixes the issue and does not introduce any new layout issues? I described the scenario where it won't work, but hopefully it is not common enough nesting pattern. |
@WoLewicki I've tested with the PR and it fixes header jump but only for vertical. Horizontal jumps looks still there. Not know if this is another issue or not connected this issue though.
With SecondStack: Without SecondStack: Screenshots saved before the navigate transition ends. With PR vertical jumps gone but horizontal still there: RPReplay_Final1626991190.mp4 |
@burakgormek I tested the snack you provided and it seems that unfortunately it is a different problem than the one fixed by the PR and will not be easy to resolve. Could you submit another issue with suitable description and this reproduction and we will close this one as #1025 is merged? |
I came up with another option of how to resolve these issues, which is making |
@WoLewicki Btw I think you linked the wrong/old one. I tested #1029 Final result: RPReplay_Final1627492103.mp4 |
Yeah, I meant #1029, sorry. 😅 |
I have the same issue demonstrated in the original post on this issue when using nested native stack navigators. I tested both of the following:
|
@WoLewicki I'll throw in my two cents. I have the same issue with a native stack navigator nested in a tab navigator nested in another native stack navigator. import React from "react";
import { Button, SafeAreaView } from "react-native";
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator, NativeStackScreenProps } from "react-native-screens/native-stack";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
const RootStack = createNativeStackNavigator();
const BottomTabs = createBottomTabNavigator();
const ChildStack = createNativeStackNavigator();
type RootStackParamsList = {
BottomTabsScreen: undefined;
};
const HomeScreen = ({navigation}: NativeStackScreenProps<RootStackParamsList>) => (
<SafeAreaView>
<Button
title="Navigate to BottomTabsScreen"
onPress={() => navigation.navigate("BottomTabsScreen")} />
</SafeAreaView>
);
const BottomTabsScreen = () => (
<BottomTabs.Navigator
initialRouteName="FirstBottomTabScreen"
screenOptions={{headerShown: false}}>
<BottomTabs.Screen
name="FirstBottomTabScreen"
component={FirstBottomTabScreen} />
</BottomTabs.Navigator>
);
const FirstBottomTabScreen = () => (
<ChildStack.Navigator
initialRouteName="ChildStackScreen">
<ChildStack.Screen
name="ChildStackScreen"
component={ChildStackScreen} />
</ChildStack.Navigator>
);
const ChildStackScreen = () => null;
const App = () => (
<NavigationContainer>
<RootStack.Navigator
initialRouteName="HomeScreen"
screenOptions={{headerShown: false}}>
<RootStack.Screen
name="HomeScreen"
component={HomeScreen} />
<RootStack.Screen
name="BottomTabsScreen"
component={BottomTabsScreen} />
</RootStack.Navigator>
</NavigationContainer>
);
export default App; |
Did you patch react-navigation PR with #1029? |
I did. It was a bit tricky to figure out how to do it in package.json, but this seemed to work for me: I didn't need to make any other changes to my code, correct? |
@burakgormek no, but after having done that, the issue is gone as well. To clarify, I installed #1029 and #9772 from react-navigation. |
@swrobel this worked for me:
|
I think it would be easiest to just change it in your |
Yes |
Not for me, although I will re-test & post a repro if I'm able to create one outside of my project. I had to upgrade to react-navigation 6.x as part of this testing, so I need to make sure I did that correctly. There are a lot of upgrade notes... |
@swrobel keep in mind that it won't work if you have a |
Do you mean a non-native stack navigator nested inside a native-stack? I don't have that setup, but I do have nested native-stack navigators. |
having a similar issue. header.issue.mp4 |
@a-eid it still happens after incorporating both PRs mentioned in #619 (comment)? @swrobel I meant the first scenario, so it should be fine. Please provide a repo with reproduction then, would be best if it already had the needed changes e.g. by using patch-package. |
@WoLewicki issue still happening with the latest release |
@a-eid You have to patch react-navigation PR which is not merged yet. |
@burakgormek thanks alot, I confirm that patching react navigation has fixed the issue for me. cc @WoLewicki |
@a-eid how did you patch it? |
I only needed to patch the bottom tab lib, also you need to be using version 6. you need to open the package inside
diff --git a/node_modules/@react-navigation/bottom-tabs/src/views/BottomTabView.tsx b/node_modules/@react-navigation/bottom-tabs/src/views/BottomTabView.tsx
index 63a0895..32fa437 100644
--- a/node_modules/@react-navigation/bottom-tabs/src/views/BottomTabView.tsx
+++ b/node_modules/@react-navigation/bottom-tabs/src/views/BottomTabView.tsx
@@ -92,6 +92,7 @@ export default function BottomTabView(props: Props) {
<SafeAreaProviderCompat>
<MaybeScreenContainer
enabled={detachInactiveScreens}
+ hasTwoStates
style={styles.container}
>
{routes.map((route, index) => {
diff --git a/node_modules/@react-navigation/bottom-tabs/src/views/ScreenFallback.tsx b/node_modules/@react-navigation/bottom-tabs/src/views/ScreenFallback.tsx
index 36789cf..f4bb975 100644
--- a/node_modules/@react-navigation/bottom-tabs/src/views/ScreenFallback.tsx
+++ b/node_modules/@react-navigation/bottom-tabs/src/views/ScreenFallback.tsx
@@ -22,6 +22,7 @@ export const MaybeScreenContainer = ({
...rest
}: ViewProps & {
enabled: boolean;
+ hasTwoStates: boolean;
children: React.ReactNode;
}) => {
if (Screens?.screensEnabled?.()) { this applies changes to the bottom-tabs only, if you're using a drawer you'd need to edit the package files as well. |
When you have a nested navigators like this:
NativeStack -> BottomTabs -> NativeStack
, it creates issues when rendering the header from the innermost NativeStack. Only appears to happen when there some other navigator anywhere between two NativeStack ones. For exampleStack -> BottomTabs -> NativeStack
works correctly andNativeStack -> NativeStack
work correctly.This seems to be the same bug as #540.
https://github.com/dotconnor/ScreensHeader
Expected
Actual
The text was updated successfully, but these errors were encountered: