-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Support Android predictive back animation when exiting app #55211
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
base: main
Are you sure you want to change the base?
Conversation
This callback prevents the predictive back animation when exiting the app. Apps that use predictive back can disable the callback to restore the exiting animation
The callback might've been manually disabled, in which case want to leave it disabled
|
@grahammendick Thanks for raising the issue. Can you add a bit more detail about what the code does and also how this relates to Navigation router? I'm not sure if I have a clear understanding about this. |
|
@alanleedev Thanks for the response 🙏 This issue impacts any navigation library for React Native that supports the predictive back gesture on Android. As far as I'm aware, my Navigation router is the only one that currently does, which is why I mention it. But when React Native Screens adds support then they'll also face this same issue. When I say "supports the predictive back gesture" I mean that the back is handled by the native side running an animation as the gesture progresses. You can take a look at my twitter sample to see it working. The predictive back animation runs perfectly when the back stays within the app because this is handled by my Navigation router (using the in-built predictive back support provided by the Android It's important for the animation to run otherwise we go back to the bad old days of users accidentally exiting the app when they didn't mean to. I mention in the summary that it's not reasonable to bring the "exit app" gesture animation back for navigation libraries that don't support the predictive back gesture. That would involve a significant rewrite where the But allowing React Native's |
Bulls eye! Exactly, we're working on new stack implementation right now and we run in Our issue is even more severe as we use the supportFragmentManager directly, and having this callback prevents the predictiveBackGesture on fragment manager level (not really sure yet why it happens exactly, digging into it). I'm sure we can workaround that, however the issue with predictive back gesture between activity and launcher screen remains. I'd be great to be able to disable the It might make sense to disable it through Approach with Happy to discuss more here. |
I don't think you want to throw in this scenario. For example, a 3rd party Tab library might use |
Summary:
When onBackPressed was migrated to OnBackPressedCallback react native lost the predictive back animation when exiting an app. This PR aims to restore the predictive back animation for apps that support predictive back (it's not reasonable to try and bring this back for all apps). Apps that support predictive back, for example, those that use the Navigation router, can disable the callback in their Activity.
Expected behavior (and before the migration)
Screen.Recording.2026-01-16.at.17.04.02.mov
Current behavior
Screen.Recording.2026-01-16.at.17.04.58.mov
Changelog:
[ANDROID] [FIXED] - Support predictive back animation when exiting app
Test Plan:
Here is the the Navigation router sample running with the callback disabled
Screen.Recording.2026-01-16.at.17.14.05.mov