Skip to content

Commit

Permalink
Android: Added back touch event handling based on reactTag
Browse files Browse the repository at this point in the history
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
  • Loading branch information
fkgozali authored and facebook-github-bot committed Jun 10, 2022
1 parent 1b6584b commit 8b83726
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8b83726

Please sign in to comment.