Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Unintended back navigation occurs when rapidly tapping the back button in topicScreen #1571

Open
3 tasks done
YiBeomSeok opened this issue Aug 14, 2024 · 0 comments · May be fixed by #1572
Open
3 tasks done
Labels
bug Something isn't working

Comments

@YiBeomSeok
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Is there a StackOverflow question about this issue?

  • 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

  • I agree to follow this project's Code of Conduct
@YiBeomSeok YiBeomSeok added the bug Something isn't working label Aug 14, 2024
@YiBeomSeok YiBeomSeok linked a pull request Aug 14, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant