I am facing a bug where if I press the back button...
# compose-android
f
I am facing a bug where if I press the back button when I'm in the middle of navigating from Screen A to Screen B, it will partially show the screen in between A and B. It just freezes at there until I press back again. Never saw this issue in whole life of my Android dev career until I tried Compose. Did I do something wrong? Or this is just Compose not being prod-ready. Below is a screenshot of what I wanted to say.
Copy code
@Composable
fun FileManagerNavHost(
    modifier: Modifier = Modifier,
    navController: NavHostController,
) {
    NavHost(
        navController = navController,
        startDestination = HomePageRoute,
        enterTransition = {
            slideIntoContainer(
                AnimatedContentTransitionScope.SlideDirection.Start,
                tween(500)
            )
        },
        exitTransition = {
            slideOutOfContainer(
                AnimatedContentTransitionScope.SlideDirection.Start,
                tween(500)
            )
        },
        modifier = modifier
    ) {
        homePageRoute(
            onNavigateToFileList = { directory ->
                navController.navigateSafely(FileListRoute(directory))
            }
        )
        fileListRoute(
            onNavigateToFileList = { directory ->
                navController.navigateSafely(FileListRoute(directory))
            }
        )
        imageViewerRoute()
    }
}
Copy code
fun NavController.navigateSafely(route: Route) {
    val currentBackStackEntry = this.currentBackStackEntry ?: return
    if (currentBackStackEntry.lifecycle.currentState == Lifecycle.State.RESUMED) {
        this.navigate(route)
    }
a
Try to simiplify it, remove all the custom code and animation and see if that helps.
f
This is an issue with Compose Navigation itself.