forked from software-mansion/react-native-screens
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(android): disappearing search icon on opening transparent modal (s…
…oftware-mansion#2274) ## Description This PR fixes disappearing search icon of the previous screen when navigating to a transparent modal with hidden header. When navigating to a screen with `presentation: "transparentModal"` and `headerShown: false` the toolbar menu was unnecessarily updated with new screen's options. The update caused the search icon of the previous screen (still visible in the background) to disappear. Fixes software-mansion#2271 . ## Changes - added `Test2271.tsx` repro - updating the toolbar menu conditionally ## Screenshots / GIFs ### Before https://github.com/user-attachments/assets/390f054b-b003-4b7f-b6f5-9aa9fd936dca ### After https://github.com/user-attachments/assets/cb1fc795-c7a3-4514-9bb5-b7e1995d0b90 ## Test code and steps to reproduce - use `Test2271.tsx` for repro ## Checklist - [x] Included code example that can be used to test this change - [x] Ensured that CI passes
- Loading branch information
Showing
5 changed files
with
98 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters