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

Đang mở
#1,571 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

  • #1572 của @YiBeomSeok — đã đóng, không merge

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
38/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
android, kotlin
Lĩnh vực
mobile-dev

Hướng nghiên cứu

Bắt đầu từ entry point topicScreen và kiểm tra callback onBackClick của nó cùng các phương thức listDetailNavigator mà nó sử dụng. Thay đổi được hoàn tất khi các lần chạm nút quay lại liên tiếp chỉ điều hướng khi canNavigateBack() cho phép; issue không nêu tên tệp kiểm thử nào.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
Kotlin
Star
22.1k
Fork
4.7k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của android/nowinandroid

Tất cả issue của android/nowinandroid

Issue tương tự

Thêm issue về Kotlin

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.