Skip to content

Commit 773e59b

Browse files
authored
Only cancel JS responder when activating recognizer comes from Gesture Handler (#2533)
## Description Upon activation of a gesture recognizer, the iOS root view recognizer would cancel JS responders so they wouldn't conflict with each other, however this is currently done even if the activating recognizer doesn't come from Gesture Handler which may result in different behaviors for custom native components when used with or without Gesture Handler. This PR adds a check to ensure the activating recognizer has an associated gesture handler before canceling JS responders. Fixes #2530 ## Test plan Tested on Example app and on the repro from the linked issue
1 parent cddaedb commit 773e59b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ios/RNRootViewGestureRecognizer.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,13 @@ - (BOOL)canPreventGestureRecognizer:(UIGestureRecognizer *)preventedGestureRecog
5757
- (BOOL)canBePreventedByGestureRecognizer:(UIGestureRecognizer *)preventingGestureRecognizer
5858
{
5959
// When this method is called it means that one of handlers has activated, in this case we want
60-
// to send an info to JS so that it cancells all JS responders
61-
[self.delegate gestureRecognizer:preventingGestureRecognizer didActivateInViewWithTouchHandler:self.view];
60+
// to send an info to JS so that it cancells all JS responders, as long as the preventing
61+
// recognizer is from Gesture Handler, otherwise we might break some interactions
62+
RNGestureHandler *handler = [RNGestureHandler findGestureHandlerByRecognizer:preventingGestureRecognizer];
63+
if (handler != nil) {
64+
[self.delegate gestureRecognizer:preventingGestureRecognizer didActivateInViewWithTouchHandler:self.view];
65+
}
66+
6267
return [super canBePreventedByGestureRecognizer:preventingGestureRecognizer];
6368
}
6469

0 commit comments

Comments
 (0)