chansek
03/22/2022, 7:30 PM2.4.0-alpha04
Whenever I do navController.popBackStack()
, I see the behavior attached in the video. For now the fix is by downgrading the navigation version.
"androidx.navigation:navigation-compose:2.4.0-alpha04" // Working fine
vs
"androidx.navigation:navigation-compose:2.4.0-alpha05" or above // Doesn't work
Is there any way to fix it up or I have to wait until it is being fixed by Google?
This behavior is found till 2.5.0-alpha03
Looks like this commit caused the issue:
https://android-review.googlesource.com/c/platform/frameworks/support/+/1750073
Ian Lake
03/22/2022, 8:34 PMpopBackStack()
?Ian Lake
03/22/2022, 8:34 PMchansek
03/23/2022, 3:04 AMACTION_UP
, I call onBackPressed
val dis = LocalOnBackPressedDispatcherOwner.current?.onBackPressedDispatcher
Scaffold(
topBar = {
AppBar {
BackMenu {
dis?.onBackPressed()
}
}
},
modifier = Modifier.fillMaxSize()
) {
}
chansek
03/23/2022, 3:30 AMpopBackStack()
val dis = LocalOnBackPressedDispatcherOwner.current?.onBackPressedDispatcher
Scaffold(
topBar = {
AppBar {
BackMenu {
navController.popBackStack()
}
}
},
modifier = Modifier.fillMaxSize()
) {
}
chansek
03/23/2022, 6:19 AMIan Lake
03/23/2022, 1:25 PMchansek
03/23/2022, 1:29 PMalpha04
and alpha05
which caused this recomposition?
There is another problem. If I have a stack A -> B -> C
and by doing navController.popBackStack()
, on few scenarios, I see it comes back to A
instead of B
Ian Lake
03/23/2022, 1:33 PMIan Lake
03/23/2022, 1:34 PMchansek
03/23/2022, 1:37 PMchansek
03/23/2022, 1:37 PMIan Lake
03/23/2022, 1:52 PMchansek
03/23/2022, 2:04 PMButton(
onClick = {
println("Details Screen Clicked")
onClick()
}
) {
Text("Go Back")
}
chansek
03/23/2022, 2:05 PMchansek
03/23/2022, 3:32 PMalpha04
, the log prints as
I/System.out: Details Screen Clicked
I/System.out: List ScreenIan Lake
03/23/2022, 4:46 PMIan Lake
03/23/2022, 4:47 PMIan Lake
03/23/2022, 4:48 PMchansek
03/23/2022, 4:50 PM