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 <Touchable>, otherwise touches are not delivered to the component.

Reviewed By: yungsters

Differential Revision: D24219223

fbshipit-source-id: 17b4e3460735371553ee0d30b41776a977f8eafb
This commit is contained in:
Samuel Susla 2020-10-12 01:57:12 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 748aa13747
Коммит eb7701c1ec
1 изменённых файлов: 11 добавлений и 8 удалений

Просмотреть файл

@ -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<RCTTouchableComponentViewProtocol>)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<RCTTouchableComponentViewProtocol>)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;
}