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
'useReanimatedHeaderHeight' doesn't respond to changes in search bar focus #1951
Comments
Hi @ha3, thanks for reporting this issue! On the large header: Screen.Recording.2023-11-02.at.15.38.10.movOn small header: Screen.Recording.2023-11-02.at.15.39.31.movHere's my code that reproduces this issue. Here I'm using Native Stack v5, but this shouldn't have an impact on the problem. Can you try to compare if you're using the shared value correctly? import { ScrollView, StyleSheet, Text } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import {
useReanimatedHeaderHeight,
ReanimatedScreenProvider,
} from 'react-native-screens/reanimated';
import Animated, { useAnimatedStyle } from 'react-native-reanimated';
import { createNativeStackNavigator } from 'react-native-screens/native-stack';
import { FullWindowOverlay } from 'react-native-screens';
import React from 'react';
const Stack = createNativeStackNavigator();
function ExampleScreen() {
const headerHeight = useReanimatedHeaderHeight();
const animatedStyles = useAnimatedStyle(() => ({
transform: [{ translateY: headerHeight.value }],
}));
return (
<FullWindowOverlay>
<Animated.View
style={[
{
display: 'flex',
justifyContent: 'flex-end',
alignItems: 'center',
backgroundColor: 'red',
width: '100%',
opacity: 0.5,
height: 60,
zIndex: 1,
},
animatedStyles,
]}>
<Text>I'm a header!</Text>
</Animated.View>
</FullWindowOverlay>
);
}
const Screen = () => {
return (
<>
<ScrollView
style={styles.screen}
contentContainerStyle={{
flexGrow: 1,
justifyContent: 'center',
alignItems: 'center',
}}
contentInsetAdjustmentBehavior="automatic">
<Text>Screen</Text>
</ScrollView>
<ExampleScreen />
</>
);
};
export default function App() {
return (
<ReanimatedScreenProvider>
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen
name="screen"
component={Screen}
options={{
searchBar: {
placeholder: 'Search',
},
headerTitle: 'Custom header title',
}}
/>
</Stack.Navigator>
</NavigationContainer>
</ReanimatedScreenProvider>
);
}
const styles = StyleSheet.create({
screen: {
flex: 1,
},
}); |
Actually, when I'm trying to use native stack v6 from React Navigation the issue occurs for me 💡 |
@ha3 I've tried to test Screen.Recording.2023-11-02.at.17.13.00.movCould you check if patching react-native-screens version to 3.27.0 inside whole @react-navigation monorepo is sufficient in your case? |
@tboba sorry for responding so late! Unfortunately, I couldn't run the example app in Also, I don't understand one thing. Since |
@ha3 I think that you should be right right about your meaning of screens as a peer dependency, but to be honest I don't know how peerDependencies work with different versions of packages between defined version of peerDependency and the actual dependency installed in a project. |
Hi @ha3, sorry for pretty late update about this issue, but I finally found the time to check it again 😄 However, I'll try to push forward with creating a PR for adding Cheers! 👋 Screen.Recording.2024-05-15.at.14.55.42.mov |
Description
On iOS, when the search bar is focused, the upper section of the header is collapsed. But it seems that the reanimated value from
useReanimatedHeaderHeight
doesn't get updated during focus/blur.Also on the simulator (iPhone 13 - iOS 15.5) I tested,
useReanimatedHeaderHeight
returns the value '91' but when I used the visual inspector I found it should be '96' (44 for the upper part, 52 for the search bar). I haven't tested this with other simulators–but as far as I know, they should have the same search bar height.Steps to reproduce
NavigationContainer
withReanimatedScreenProvider
.useReanimatedHeaderHeight
inside the screenSnack or a link to a repository
https://snack.expo.dev/@hozdemir/delicious-red-marshmallows
Screens version
3.27.0
React Native version
0.72.6
Platforms
iOS
JavaScript runtime
Hermes
Workflow
React Native (without Expo)
Architecture
Paper (Old Architecture)
Build type
Debug mode
Device
iOS simulator
Device model
iPhone 13 (iOS 15.5)
Acknowledgements
Yes
The text was updated successfully, but these errors were encountered: