Skip to content
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

fix(android): disappearing search icon on opening transparent modal #2274

Merged
merged 9 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,12 @@ class ScreenStackFragment :
}

override fun onPrepareOptionsMenu(menu: Menu) {
updateToolbarMenu(menu)
// If the screen is a transparent modal with hidden header we don't want to update the toolbar
// menu because it may erase the menu of the previous screen (which is still visible in these
// circumstances). See here: https://github.com/software-mansion/react-native-screens/issues/2271
if (screen.stackPresentation != Screen.StackPresentation.TRANSPARENT_MODAL || screen.headerConfig?.isHeaderHidden == false) {
updateToolbarMenu(menu)
}
alduzy marked this conversation as resolved.
Show resolved Hide resolved
return super.onPrepareOptionsMenu(menu)
}

Expand Down
83 changes: 83 additions & 0 deletions apps/src/tests/Test2271.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { NavigationContainer } from '@react-navigation/native';
import {
NativeStackScreenProps,
createNativeStackNavigator,
} from '@react-navigation/native-stack';
import React from 'react';
import { Button, StyleSheet, Text, View } from 'react-native';
import { GestureHandlerRootView } from 'react-native-gesture-handler';

type StackParamList = {
Home: undefined;
Details: undefined;
};

const Stack = createNativeStackNavigator<StackParamList>();

function HomeScreen({
navigation,
}: NativeStackScreenProps<StackParamList, 'Home'>) {
return (
<View style={styles.container}>
<Text>Home Screen</Text>
<Button
title="Open Modal"
onPress={() => navigation.navigate('Details')}
/>
</View>
);
}
function DetailScreen({
navigation,
}: NativeStackScreenProps<StackParamList, 'Details'>) {
return (
<View style={styles.container}>
<Text>DetailScreen</Text>
<Button title={'Bo Back'} onPress={navigation.goBack} />
</View>
);
}

export default function App(): React.JSX.Element {
return (
<GestureHandlerRootView style={{ flex: 1 }}>
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen
options={{
headerSearchBarOptions: {
autoCapitalize: 'none',
placement: 'stacked',
hideWhenScrolling: false,
shouldShowHintSearchIcon: false,
hideNavigationBar: true,
tintColor: 'blue',
textColor: 'black',
hintTextColor: 'black',
headerIconColor: 'black',
},
}}
name="Home"
component={HomeScreen}
/>
<Stack.Screen
name="Details"
component={DetailScreen}
options={{
headerShown: false,
presentation: 'transparentModal',
}}
/>
</Stack.Navigator>
</NavigationContainer>
</GestureHandlerRootView>
);
}

const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
});
1 change: 1 addition & 0 deletions apps/src/tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,6 @@ export { default as Test2231 } from './Test2231';
export { default as Test2232 } from './Test2232';
export { default as Test2235 } from './Test2235';
export { default as Test2252 } from './Test2252';
export { default as Test2271 } from './Test2271';
export { default as TestScreenAnimation } from './TestScreenAnimation';
export { default as TestHeader } from './TestHeader';
Loading