-
Notifications
You must be signed in to change notification settings - Fork 7k
Icons get cut off in App Bar on Android using headerRight (but not if hot-swapped in) #36793
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
Comments
After some more testing, this appears specific to Expo 53 or the corresponding Expo Go version. Neither 51 nor 52 have the issue. |
Hey! Thanks for opening the issue. Seems that this issue is related to Expo Router also inserts a Safe Area Context which might be misbehaving on these particular devices. If your able to reproduce the issue without Expo Router, I would recommend closing this issue and reopening under the React Navigation repo, as they are the maintainers of the |
I put together an example trying to demonstrate the bug independent of Expo: But, I found I couldn't replicate the issue through their standard way of running apps ( I then made a fresh example in Expo (no router) using this icon library instead of Expo Example (no router, no Expo icons) Here are the results from each configuration I tested:
❗ Changes to "Cut off" when wrapped in So, it appears the only way to trigger the issue is to use Expo 53, and then either a) use Expo Go or b) use I'll file the bug there too regardless, but since I have very little knowledge of how these two interact, I'll wait for you to determine whether these results mean we should close this one and assume it's something that should be fixed in |
Use the React Navigation - "Stack" I have had this issue pop up and it can be frustrating, there is an issue in the native-stack with rendering a "headerRight" must be an issue in expo-router as well? If you use Stack you can add the code this way, it will properly render your icon on the right side of the header: npm install @react-navigation/native
npm install @react-navigation/stack
npm install react-native-gesture-handler import { NavigationContainer } from '@react-navigation/native'; //This container needs to wrap anything in your app that uses Navigation or error
import { createStackNavigator } from '@react-navigation/stack';
import {Ionicons} from '@expo/vector-icons
const Stack = createStackNavigator();
export default function RootLayout() {
return (
<NavigationContainer>
<Stack.Navigator
screenOptions={{
headerRight: () => <Ionicons name="accessibility" size={24} color="black" /> //add a style={{}} to add margin and such
}}
/>
<Stack.Screen name="Home" component={HomeScreen} /> //if you are using screens
//... content will go here ...
</Stack.Navigator>
</NavigationContainer>
)
} References: |
@HarambeHombre Yes, I'm getting this result too - changing the no-router test above to use This is in addition to the other differences between the two. As you mentioned, this affects Expo Router too. There seems to be a way around this here: https://expo.github.io/router/docs/migration/react-navigation/stack but ideally we would be able to get the benefits of |
Have you tried adding a style to it to try to force everything to line up? Maybe create a custom icon component with the Ionicons wrapped in a view that can be styled and add it to the headerRight? All I can think is there is an update or state issue with rendering the icon, because like you said if you hot-load fix it, the icon appears until you reload. Other times the icon looks like it wants to render like normal and then it gets a major margin left boost lol. Also, I fully agree we should be able to just get this functionality whichever route we choose to use. |
Minimal reproducible example
https://github.com/SubsequentlySneeds/expo-icon-header-bug-mre
Steps to reproduce
Platforms
I tested this on the Expo Go app on two Android devices:
Although I skipped web and iPhone to keep the example minimal, neither of these platforms had the issue when I first experienced the bug.
Steps
_layout.jsx
the<Text>
line is uncommented and the<Ionicons>
line is commented.npx expo start
. From a clean start of Expo Go, scan the QR code from the terminal. The screen should look like:<Text>
line and uncomment the<Ionicons>
line in_layout.jsx
. Save the file to hot reload. The screen should now look like:Note that the accessibility icon is (horizontally) fully visible.
Note that the accessibility icon is now almost entirely cut off - only a small section of one of the arms can be seen on the right.
<Ionicons>
line and uncomment the<Text>
line in_layout.jsx
. The screen should now look like:Here, only a sliver of the leftmost part of the R is visible.
Bug
The desired behavior is that the
<Ionicons>
renders visibly in the right part of the App Bar, as it does after hot-swapping it for<Text>
. Because this is platform-specific and behaves inconsistently with respect to hot-swapping in Expo Go, I filed under SDK.Other Notes
Environment
Expo Doctor Diagnostics
The text was updated successfully, but these errors were encountered: