From 8b837268b49fd4e72a05f955c20702c457a68fab Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Fri, 10 Jun 2022 01:11:20 -0700 Subject: [PATCH] Android: Added back touch event handling based on reactTag Summary: It turned out the previous attempt to rely on the Event's UIManagerType wasn't sufficient, as not all Fabric touch event had a surfaceId set on them, e.g. Modal etc. This brings back the UIManagerType detection based on reactTag, but do it only for non-rootView to keep handling touch via the right dispatcher for rootView as well. Changelog: [Fixed][Android] Bring back non-rootview touch handling based on reactTag Reviewed By: JoshuaGross, sshic Differential Revision: D37063335 fbshipit-source-id: 76e2d7ae5f00006c5ecaf50c86920ea6e85155b7 --- .../com/facebook/react/uimanager/events/Event.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/Event.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/Event.java index 94515d47be1273..0b6a1140c8edab 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/Event.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/Event.java @@ -12,6 +12,7 @@ import com.facebook.react.common.SystemClock; import com.facebook.react.uimanager.IllegalViewOperationException; import com.facebook.react.uimanager.common.UIManagerType; +import com.facebook.react.uimanager.common.ViewUtil; /** * A UI event that can be dispatched to JS. @@ -80,7 +81,14 @@ protected void init(int surfaceId, int viewTag, long timestampMs) { // non-Fabric UIManager, and we cannot use the ViewTag for inference since it's not controlled // by RN and is essentially a random number. // At some point it would be great to pass the SurfaceContext here instead. - mUIManagerType = (surfaceId == -1 ? UIManagerType.DEFAULT : UIManagerType.FABRIC); + @UIManagerType + int uiManagerType = (surfaceId == -1 ? UIManagerType.DEFAULT : UIManagerType.FABRIC); + if (uiManagerType == UIManagerType.DEFAULT && !ViewUtil.isRootTag(viewTag)) { + // TODO (T123064648): Some events for Fabric still didn't have the surfaceId set, so if it's + // not a React RootView, double check if the tag belongs to Fabric. + uiManagerType = ViewUtil.getUIManagerType(viewTag); + } + mUIManagerType = uiManagerType; mTimestampMs = timestampMs; mInitialized = true;