Skip to content

Commit 7b62810

Browse files
author
Alejo
committed
product selection with Talkback enabled
1 parent 4fb8bf8 commit 7b62810

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/ProductListFragment.kt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,22 @@ class ProductListFragment :
626626
}
627627
}
628628

629+
// Some edge cases in product selection mode, like tapping the screen with 4 fingers or using TalkBack,
630+
// cause the product's onClick listener to gain focus over the selection tracker.
631+
// This quick fix will prevent the app from entering an unexpected status when the app is in selection mode.
632+
private fun shouldPreventDetailNavigation(remoteProductId: Long): Boolean {
633+
if (viewModel.isSelecting()) {
634+
tracker?.let { selectionTracker ->
635+
if (selectionTracker.isSelected(remoteProductId)) selectionTracker.deselect(remoteProductId)
636+
else selectionTracker.select(remoteProductId)
637+
}
638+
return true
639+
}
640+
return false
641+
}
642+
629643
private fun onProductClick(remoteProductId: Long, sharedView: View?) {
630-
if (viewModel.isSelecting()) return
644+
if (shouldPreventDetailNavigation(remoteProductId)) return
631645
(activity as? MainNavigationRouter)?.let { router ->
632646
if (sharedView == null) {
633647
router.showProductDetail(remoteProductId, enableTrash = true)

0 commit comments

Comments
 (0)