nowinandroid
nowinandroid copied to clipboard
[Bug]: Unintended back navigation occurs when rapidly tapping the back button in `topicScreen`
Is there an existing issue for this?
- [X] I have searched the existing issues
Is there a StackOverflow question about this issue?
- [X] I have searched StackOverflow
What happened?
When rapidly tapping the back button in the topicScreen component, unintended back navigation occurs. The current implementation of the onBackClick directly calls listDetailNavigator.navigateBack() without first checking if navigation is allowed, leading to unexpected behavior.
I expected the back navigation to occur only when it is allowed, preventing any unintended navigation when the back button is tapped multiple times in quick succession. Specifically, the onBackClick should check listDetailNavigator.canNavigateBack() before calling navigateBack() to ensure that the back navigation is permitted.
topicScreen(
showBackButton = !listDetailNavigator.isListPaneVisible(),
onBackClick = {
if(listDetailNavigator.canNavigateBack()) {
listDetailNavigator.navigateBack()
}
},
onTopicClick = ::onTopicClickShowDetailPane,
)
In typical scenarios using a standard navController, this issue can be avoided by checking the lifecycle state of the navBackStackEntry before popping the back stack:
if (navController.currentBackStackEntry?.lifecycle?.currentState == Lifecycle.State.RESUMED) {
navController.popBackStack()
}
Relevant logcat output
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct