Skip to content

Commit 20e4bb7

Browse files
committed
fix(android): edge case of gesture not working with bottomSheet
1 parent 8e06a0b commit 20e4bb7

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/gesturehandler/gesturehandler.android.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -548,18 +548,22 @@ export class Manager extends ManagerBase {
548548

549549
findRegistry(view: View): com.swmansion.gesturehandler.GestureHandlerRegistryImpl {
550550
let registry: com.swmansion.gesturehandler.GestureHandlerRegistryImpl;
551+
let parent = view.parent;
552+
// first test for GestureRootView
553+
// otherwise it could fail with components like BottomSheet
554+
// where the bottomSheet parent is set to app rootView (which could be a page)
555+
// thus the registry to add the handler would not be the same
556+
// as the one use for touch
557+
while (parent) {
558+
if (parent instanceof GestureRootView) {
559+
return parent.registry;
560+
}
561+
parent = parent.parent;
562+
}
563+
551564
const page = view.page as PageGestureExtended;
552565
if (page) {
553566
registry = page.registry;
554-
} else {
555-
// no root page try to find a parent GestureRootView
556-
let parent = view.parent;
557-
while (parent) {
558-
if (parent instanceof GestureRootView) {
559-
return parent.registry;
560-
}
561-
parent = parent.parent;
562-
}
563567
}
564568
return registry;
565569
}

0 commit comments

Comments
 (0)