Jonathan
11/26/2025, 4:38 AMNavHost) where you’re unable to return to a given “top level destination” after navigating to another “top level destination” with route args? To exit this erroneous state, you must manually pop the top-most “top level destination” from the back stack then everything works as it should. I’m able to reproduce this bug in the Now In Android app so I know it’s not a bug unique to my app/implementation. If anyone has any insights on how to work around this bug it would be more than appreciated.Jonathan
12/01/2025, 5:00 PMIan Lake
12/01/2025, 6:23 PMIan Lake
12/01/2025, 6:24 PMsaveState + restoreState flags, you are indeed going to run into issuesJonathan
12/01/2025, 6:38 PMfun navigateToTopLevelDestination(topLevelDestination: TopLevelDestination) {
val topLevelNavOptions = navOptions {
popUpTo(route = navController.graph.findStartDestination().route!!) {
saveState = true
}
launchSingleTop = true
restoreState = true
}
when (topLevelDestination) {
TopLevelDestination.Home -> navController.navigate(NavDestinations.Home, topLevelNavOptions)
TopLevelDestination.Schedules -> navController.navigate(NavDestinations.Times(), topLevelNavOptions)
TopLevelDestination.Settings -> navController.navigate(NavDestinations.Settings, topLevelNavOptions)
}
}
Looks like I was calling to a different function that was properly setting saveState + restoreState flags.Jonathan
12/01/2025, 6:41 PMJonathan
12/01/2025, 6:43 PMJonathan
12/01/2025, 6:47 PMpopUp<top-level#1> ?Ian Lake
12/01/2025, 7:01 PMsaveState and restoreState, the entire tab, including screens you have navigated to while on that tab, are expected to be saved and restored, yesJonathan
12/01/2025, 7:03 PMsaveState and restoreState selecting the top-level#1 nav bar item does nothing. Why is this?Ian Lake
12/01/2025, 8:46 PMIan Lake
12/01/2025, 8:48 PMJonathan
12/01/2025, 8:52 PMIan Lake
12/01/2025, 9:04 PMSo the app loads to the first top-level screen. Then the details page is opened, next a bug launches to a second top-level screen.And the selected item on the nav bar shows them transitioning to the second tab at this point, yes? That's the signal to users that they've done the exact same thing as if they clicked on the second tab themselves
Jonathan
12/01/2025, 9:07 PMIan Lake
12/01/2025, 9:09 PM