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
This commit is contained in:
Mehdi Mulani 2018-08-13 11:26:15 -07:00 committed by Facebook Github Bot
parent 97fd096671
commit 66089bf150
1 changed files with 2 additions and 1 deletions

View File

@ -13,6 +13,7 @@
#import "RCTBridge.h" #import "RCTBridge.h"
#import "RCTEventDispatcher.h" #import "RCTEventDispatcher.h"
#import "RCTLog.h" #import "RCTLog.h"
#import "RCTSurfaceView.h"
#import "RCTTouchEvent.h" #import "RCTTouchEvent.h"
#import "RCTUIManager.h" #import "RCTUIManager.h"
#import "RCTUtils.h" #import "RCTUtils.h"
@ -246,7 +247,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithTarget:(id)target action:(SEL)action
- (void)_cacheRootView - (void)_cacheRootView
{ {
UIView *rootView = self.view; UIView *rootView = self.view;
while (rootView.superview && ![rootView isReactRootView]) { while (rootView.superview && ![rootView isReactRootView] && ![rootView isKindOfClass:[RCTSurfaceView class]]) {
rootView = rootView.superview; rootView = rootView.superview;
} }
_cachedRootView = rootView; _cachedRootView = rootView;