From eb7701c1ec445bf81ea0e8434ddc57707f7da69d Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Mon, 12 Oct 2020 01:57:12 -0700 Subject: [PATCH] Search for Fabric managed view when creating Touch Summary: Changelog: [Internal] If `uiTouch.view` isn't managed by Fabric, go up the view hierarchy to find first view that is. This is important for host views wrapped by , otherwise touches are not delivered to the component. Reviewed By: yungsters Differential Revision: D24219223 fbshipit-source-id: 17b4e3460735371553ee0d30b41776a977f8eafb --- React/Fabric/RCTSurfaceTouchHandler.mm | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/React/Fabric/RCTSurfaceTouchHandler.mm b/React/Fabric/RCTSurfaceTouchHandler.mm index 387908ccf6d..04e09ddfd57 100644 --- a/React/Fabric/RCTSurfaceTouchHandler.mm +++ b/React/Fabric/RCTSurfaceTouchHandler.mm @@ -102,18 +102,21 @@ static void UpdateActiveTouchWithUITouch( static ActiveTouch CreateTouchWithUITouch(UITouch *uiTouch, UIView *rootComponentView, CGPoint rootViewOriginOffset) { - UIView *componentView = uiTouch.view; - ActiveTouch activeTouch = {}; - if ([componentView respondsToSelector:@selector(touchEventEmitterAtPoint:)]) { - activeTouch.eventEmitter = [(id)componentView - touchEventEmitterAtPoint:[uiTouch locationInView:componentView]]; - activeTouch.touch.target = (Tag)componentView.tag; + // Find closest Fabric-managed touchable view + UIView *componentView = uiTouch.view; + while (componentView) { + if ([componentView respondsToSelector:@selector(touchEventEmitterAtPoint:)]) { + activeTouch.eventEmitter = [(id)componentView + touchEventEmitterAtPoint:[uiTouch locationInView:componentView]]; + activeTouch.touch.target = (Tag)componentView.tag; + activeTouch.componentView = componentView; + break; + } + componentView = componentView.superview; } - activeTouch.componentView = componentView; - UpdateActiveTouchWithUITouch(activeTouch, uiTouch, rootComponentView, rootViewOriginOffset); return activeTouch; }