Skip to content

Commit 60b0d54

Browse files
authored
fix(Fabric,iOS): cancel conflicting presses in modals on swipe back gesture (#2943)
## Description Previously, when looking for `RCTSurfaceTouchHanlder` we've looked only for `RCTSurfaceView`, however on Fabric in modal view hierarchies, the `RCTSurfaceView` can not be reached directly when iterating over UIKit view ancestor chain. However, we do attach `RCTSurfaceTouchHanlder` to every `RNSModalScreen` anyway & we can use that to dispatch / cancel appropriate events. ## Changes :point_up: ## Test code and steps to reproduce `Test780` should now work on Fabric ## Checklist - [x] Included code example that can be used to test this change - [x] Ensured that CI passes
1 parent c188d35 commit 60b0d54

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ios/utils/UIView+RNSUtility.mm

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
21
#import "UIView+RNSUtility.h"
32

43
#ifdef RCT_NEW_ARCH_ENABLED
54
#import <React/RCTSurfaceView.h>
5+
#import "RNSModalScreen.h"
66
#endif
77

88
@implementation UIView (RNSUtility)
@@ -17,7 +17,10 @@ - (nullable RNS_TOUCH_HANDLER_ARCH_TYPE *)rnscreens_findTouchHandlerInAncestorCh
1717
// hosts `RCTSurfaceTouchHandler` as a private field. When initialised, `RCTSurfaceTouchHandler` is attached to the
1818
// surface view as a gestureRecognizer <- and this is where we can lay our hands on it.
1919

20-
while (parent != nil && ![parent isKindOfClass:RCTSurfaceView.class]) {
20+
// On Fabric, every screen not mounted under react root view has it's own surface touch handler attached
21+
// (done when the screen is moved to window).
22+
while (parent != nil && ![parent isKindOfClass:RCTSurfaceView.class] &&
23+
![parent isKindOfClass:RNSModalScreen.class]) {
2124
parent = parent.superview;
2225
}
2326

0 commit comments

Comments
 (0)