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

Abierto
#1,571 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

  • #1572 de @YiBeomSeok — cerrado sin fusionar

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
38/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
android, kotlin
Área
mobile-dev

Línea de trabajo

Comienza en el punto de entrada topicScreen e inspecciona su callback onBackClick y los métodos de listDetailNavigator que utiliza. El cambio estará completo cuando los toques repetidos en Atrás solo naveguen mientras canNavigateBack() lo permita; en la issue no se nombra ningún archivo de prueba.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug
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
Lenguaje dominante
Kotlin
Estrellas
22.1k
Forks
4.7k
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de android/nowinandroid

Todos los issues de android/nowinandroid

Issues similares

Más issues de Kotlin

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.