Stylianos Gakis
08/31/2021, 2:12 AMStylianos Gakis
08/31/2021, 2:14 AMonClick = {
currentNavController.navigate(item.screen.route) {
popUpTo(currentNavController.graph.findStartDestination().id) {
saveState = true
}
launchSingleTop = true
restoreState = true
}
}
However at the same time, I am using this
composable(...) { from: NavBackStackEntry ->
SomeComposable(
goBack = {
if (from.lifecycleIsResumed()) {
navController.popBackStack()
}
}
)
}
coming from the official jetsnack samples because otherwise I have the problem of triggering navigation multiple times if the user spam clicks. For example on the second destination of the bottom nav, on a detail screen, if the user spam clicks the button that does navController.popBackStack()
it then sometimes pops all the way to the other bottom destination, which is not what I would expect.
But with the combination of the two, I get in this state where if I am on that composable, and I click the currently selected bottom navigation item again, then the goBack()
function just does nothing, it seems like the from: NavBackStackEntry
is never reaches the RESUMED
state, since when I remove the from.lifecycleIsResumed()
check it works again.
What a I missing here, is this workaround just not how I should “buffer” the user clicking like a maniac? Sorry if pinging is discouraged (Please do let me know if so, I won’t do it again), but I do think that if anyone definitely has an answer to this, it’s you @Ian LakeIan Lake
08/31/2021, 2:37 AMStylianos Gakis
08/31/2021, 11:06 AM7689780
and with androidx.navigation:navigation-compose:2.4.0-SNAPSHOT
and I this behaviour is still happening. So do you confirm that this is a non-expected behaviour and that I am probably not messing up somewhere else? I hope that I explained what I am doing and what goes wrong in my question above.Stylianos Gakis
08/31/2021, 11:08 AMIan Lake
08/31/2021, 3:51 PMRESUMED
state after its animation finishes. That should always be the caseStylianos Gakis
08/31/2021, 3:56 PM