-
-
Notifications
You must be signed in to change notification settings - Fork 93
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
Weird SafeAreaView Behavior on iOS when used with KeyboardToolbar #809
Comments
@RodSarhan This is how it works in my example project: ![]() And ![]() Once I'm adding |
@kirillzyusko I'll try to reproduce it in the example app and let you know |
@RodSarhan okay, thank you ❤️ |
@kirillzyusko So i was able to reproduce the issue consistently on "FabricExample" but not in "example" In App.tsx just add this instead of the existing app content and you should be able to see it, but keep in mind that you need to refresh the app (or unmount + mount the screen?) instead of relying on hot reload const Stack = createStackNavigator();
const defaultScreenOptions = {
headerShown: false,
gestureEnabled: false,
cardStyle: { backgroundColor: "#fff" },
};
const ExampleWorkingScreen = () => {
return (
<>
<SafeAreaProvider>
<SafeAreaView style={{ flex: 1, backgroundColor: "red" }}>
<View style={{ flex: 1, backgroundColor: "blue" }} />
</SafeAreaView>
</SafeAreaProvider>
<KeyboardToolbar />
</>
);
};
const ExampleWorkingScreen2 = () => {
return (
<>
<SafeAreaView style={{ flex: 1, backgroundColor: "red" }}>
<View style={{ flex: 1, backgroundColor: "blue" }} />
</SafeAreaView>
</>
);
};
const ExampleBuggyScreen = () => {
return (
<>
<SafeAreaView style={{ flex: 1, backgroundColor: "red" }}>
<View style={{ flex: 1, backgroundColor: "blue" }} />
</SafeAreaView>
<KeyboardToolbar />
</>
);
};
export default function App() {
return (
<SafeAreaProvider initialMetrics={initialWindowMetrics}>
<GestureHandlerRootView style={styles.root}>
<KeyboardProvider statusBarTranslucent>
<NavigationContainer fallback={spinner} linking={linking}>
<Stack.Navigator
initialRouteName="example"
screenOptions={defaultScreenOptions}
>
<Stack.Screen component={ExampleWorkingScreen} name="example" />
</Stack.Navigator>
</NavigationContainer>
</KeyboardProvider>
</GestureHandlerRootView>
</SafeAreaProvider>
);
} |
Thank you @RodSarhan for providing full example and sorry for a long response ❤ I managed to reproduce this problem without import "react-native-gesture-handler";
import { NavigationContainer } from "@react-navigation/native";
import { createStackNavigator } from "@react-navigation/stack";
import * as React from "react";
import { SafeAreaView, StyleSheet, View } from "react-native";
import { GestureHandlerRootView } from "react-native-gesture-handler";
import Reanimated, { useAnimatedStyle } from "react-native-reanimated";
import {
SafeAreaProvider,
initialWindowMetrics,
} from "react-native-safe-area-context";
const styles = StyleSheet.create({
root: {
flex: 1,
},
});
const Stack = createStackNavigator();
const defaultScreenOptions = {
headerShown: false,
gestureEnabled: false,
cardStyle: { backgroundColor: "#fff" },
};
const ExampleBuggyScreen = () => {
const style = useAnimatedStyle(
() => ({
transform: [{ translateY: 0 }],
}),
[],
);
return (
<>
<SafeAreaView style={{ flex: 1, backgroundColor: "red" }}>
<View style={{ flex: 1, backgroundColor: "blue" }} />
</SafeAreaView>
<Reanimated.View style={style} />
</>
);
};
export default function App() {
return (
<SafeAreaProvider initialMetrics={initialWindowMetrics}>
<GestureHandlerRootView style={styles.root}>
<NavigationContainer>
<Stack.Navigator
initialRouteName="example"
screenOptions={defaultScreenOptions}
>
<Stack.Screen component={ExampleBuggyScreen} name="example" />
</Stack.Navigator>
</NavigationContainer>
</GestureHandlerRootView>
</SafeAreaProvider>
);
} I think it's a bug in Does it make sense what I'm saying? Will you open the issue? 👀 |
Thank you very much for your support. Yeah I'll open an issue there and show them this example, cheers! I'm facing another issue with KeyboardToolbar and KeyboardAwareScrollView, where the next and previous button presses get ignored until i scroll a bit or focus another input then they start working again. It might also be not related to this repo, so i won't open an issue till i figure it out. |
So it looks like it's a problem of
I think |
I think Reanimated is causing this problem, not because of react-native-safe-area-context. import * as React from 'react';
import { SafeAreaView, View } from 'react-native';
import Reanimated, { useAnimatedStyle } from 'react-native-reanimated';
const App = () => {
const style = useAnimatedStyle(
() => ({
transform: [{ translateY: 0 }],
}),
[],
);
return (
<View style={{ flex: 1 }}>
<SafeAreaView style={{ flex: 1, backgroundColor: 'red' }}>
<View style={{ flex: 1, backgroundColor: 'blue' }} />
</SafeAreaView>
<Reanimated.View style={style} />
</View>
);
};
export default App; This example code also having problem. |
Created issue on Reanimated repository |
Thank you @kdwkr ! |
Was a bit busy the past week sorry, thanks for reporting it 🫡 |
Describe the bug
SafeAreaView from react-native-safe-area-context doesn't respect safe areas on iOS when used alongside KeyboardToolbar in the same screen.
I found this hard to debug with hot reloads, to reproduce this issue i needed to reload the app between code changes for some reason.
Notes:
I'm not sure if this is intended behavior and to which repo it should be reported, so excuse me if it's not a valid issue.
Code snippet
Working (red color is visible under the status and navigation bars):
Working (red color is visible under the status and navigation bars):
Not Working (The blue view takes over the full screen):
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Using KeyboardToolbar shouldn't cause safe area insets to be ignored.
Screenshots

Smartphone (please complete the following information):
Additional context
"react-native-safe-area-context": "5.2.0"
"react-native-edge-to-edge": "1.2.0"
The text was updated successfully, but these errors were encountered: