Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions apps/src/tests/Test2991.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import React from 'react';
import { NavigationContainer, ParamListBase } from '@react-navigation/native';
import {
NativeStackNavigationProp,
createNativeStackNavigator,
} from '@react-navigation/native-stack';
import { Button, ScrollView } from 'react-native';

type RouteParamList = {
Home: undefined;
Second: undefined;
Third: undefined;
};

type NavigationProp<ParamList extends ParamListBase> = {
navigation: NativeStackNavigationProp<ParamList>;
};

type StackNavigationProp = NavigationProp<RouteParamList>;

const Stack = createNativeStackNavigator<RouteParamList>();

const Home = ({ navigation }: StackNavigationProp) => <>
<ScrollView contentInsetAdjustmentBehavior='automatic'>
<Button title="Open second" onPress={() => navigation.navigate('Second')} />
<Button title="Open third" onPress={() => navigation.navigate('Third')} />
</ScrollView>
</>

const Second = ({ navigation }: StackNavigationProp) => <>
<ScrollView contentInsetAdjustmentBehavior='automatic'>
<Button title="Back" onPress={() => navigation.goBack()} />
</ScrollView>
</>

const Third = ({ navigation }: StackNavigationProp) => <>
<ScrollView contentInsetAdjustmentBehavior='automatic'>
<Button title="Back" onPress={() => navigation.goBack()} />
</ScrollView>
</>

export default function App() {
return (
<>
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen
name="Home"
component={Home}
options={{
headerShown: false,
headerTitle: "Long back button label"
}} />
<Stack.Screen
name="Second"
component={Second}
options={{
headerBackButtonDisplayMode: 'minimal', // <--- REQUIRED
headerTitle: "Short title"
}}
/>
<Stack.Screen
name="Third"
component={Third}
options={{
headerBackButtonDisplayMode: 'minimal',
headerTitle: "Really long title that will not fit the phone screen"
}}
/>
</Stack.Navigator>
</NavigationContainer>
</>
);
}
1 change: 1 addition & 0 deletions apps/src/tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export { default as Test2899 } from './Test2899';
export { default as Test2926 } from './Test2926'; // [E2E created](iOS): PR related to iOS search bar
export { default as Test2949 } from './Test2949'; // [E2E skipped]: can't check system bars styles
export { default as Test2963 } from './Test2963'; // [E2E created](iOS): issue related to iOS
export { default as Test2991 } from './Test2991';
export { default as Test3004 } from './Test3004';
export { default as Test3045 } from './Test3045';
export { default as Test3093 } from './Test3093';
Expand Down
5 changes: 3 additions & 2 deletions ios/RNSScreenStackHeaderConfig.mm
Original file line number Diff line number Diff line change
Expand Up @@ -608,11 +608,10 @@ + (void)updateViewController:(UIViewController *)vc
}
}

[navctr setNavigationBarHidden:shouldHide animated:animated];

[config applySemanticContentAttributeIfNeededToNavCtrl:navctr];

if (shouldHide) {
[navctr setNavigationBarHidden:true animated:animated];
navitem.title = config.title;
return;
}
Expand All @@ -627,6 +626,8 @@ + (void)updateViewController:(UIViewController *)vc
config.largeTitle ? UINavigationItemLargeTitleDisplayModeAlways : UINavigationItemLargeTitleDisplayModeNever;
#endif

[navctr setNavigationBarHidden:false animated:animated];

UINavigationBarAppearance *appearance = [self buildAppearance:vc withConfig:config];
navitem.standardAppearance = appearance;
navitem.compactAppearance = appearance;
Expand Down
Loading