Skip to content

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

@YiBeomSeok

Description

@YiBeomSeok

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions