From 7b0774811e6d7d5a5d93f5be55f5daf05f4ddfdc Mon Sep 17 00:00:00 2001 From: Mehdi Mulani Date: Mon, 13 Aug 2018 11:26:15 -0700 Subject: [PATCH] Correctly find rootView when RCTTouchHandler is in a RCTSurface Summary: @public I'm surprised this hasn't caused an issue earlier. RCTTouchHandler is hooked up to RCTSurfaceView which itself contains a rootView. Thus when this calculation happens, a root view is never found. We can't assign to the root view since it created and destroyed frequently, so it makes the most sense to look for the RCTSurfaceView here and treat it as a root view. Reviewed By: fkgozali Differential Revision: D9296840 fbshipit-source-id: ba5320583201f9d5c0176847cc6e6087b6a6459b --- React/Base/RCTTouchHandler.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/React/Base/RCTTouchHandler.m b/React/Base/RCTTouchHandler.m index 5447a9a8a9f..66ee73d93c6 100644 --- a/React/Base/RCTTouchHandler.m +++ b/React/Base/RCTTouchHandler.m @@ -13,6 +13,7 @@ #import "RCTBridge.h" #import "RCTEventDispatcher.h" #import "RCTLog.h" +#import "RCTSurfaceView.h" #import "RCTTouchEvent.h" #import "RCTUIManager.h" #import "RCTUtils.h" @@ -246,7 +247,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithTarget:(id)target action:(SEL)action - (void)_cacheRootView { UIView *rootView = self.view; - while (rootView.superview && ![rootView isReactRootView]) { + while (rootView.superview && ![rootView isReactRootView] && ![rootView isKindOfClass:[RCTSurfaceView class]]) { rootView = rootView.superview; } _cachedRootView = rootView;