Skip to content

Commit

Permalink
Fix UIManager detection in touch event emitter
Browse files Browse the repository at this point in the history
Summary:
Certain events (practically always touch events probably?) will not be correctly emitted to JS in Fabric if there is no View underneath the touch - if there is no touch target besides the ReactRootView.

We can just rely on the UIManagerType annotation on the Event, which is correct and reliable.

Instead, what we do today is derive UIManagerType from ViewTag, which is correct UNLESS the viewtag is the same as the SurfaceId, in which case we may incorrectly detect that the touch is on a non-Fabric View when in fact it is on a Fabric ReactRootView.

ViewTag is not a reliable way to detect Fabric vs non-Fabric /when looking at the RootView/, where ViewTag is the same as SurfaceId. Ironically, only Fabric RootViews have a SurfaceId at all.

Practically, this won't change anything since events emitted to ReactRootView don't go anywhere (they don't have EventEmitters). So this is a pretty low-stakes fix, but is still technically correct.

Changelog: [internal]

Reviewed By: mdvacca

Differential Revision: D34149878

fbshipit-source-id: f01da556865eb597a50cd49e9787316a0ed56f70
  • Loading branch information
JoshuaGross authored and facebook-github-bot committed Feb 10, 2022
1 parent 49f3f47 commit 9bc6c0f
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -86,7 +86,7 @@ public void receiveTouches(
@Override
public void receiveTouches(TouchEvent event) {
int reactTag = event.getViewTag();
@UIManagerType int uiManagerType = ViewUtil.getUIManagerType(reactTag);
@UIManagerType int uiManagerType = event.getUIManagerType();
if (uiManagerType == UIManagerType.FABRIC && mFabricEventEmitter != null) {
mFabricEventEmitter.receiveTouches(event);
} else if (uiManagerType == UIManagerType.DEFAULT && getEventEmitter(reactTag) != null) {
Expand Down

0 comments on commit 9bc6c0f

Please sign in to comment.