From 1b994732e49538e1c2d7c1add84df3ca6e23bfa1 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Tue, 29 Nov 2022 07:00:13 -0800 Subject: [PATCH] Fix pointer event dispatch to nested text nodes Summary: Noticed that we weren't receiving pointer events for nested Text spans when the new pointer events implementation was enabled. Changelog: [Internal] Reviewed By: lunaleaps Differential Revision: D41496672 fbshipit-source-id: 9d0ed83d1bb5f42211ec655328035651f25fa471 --- .../com/facebook/react/uimanager/JSPointerDispatcher.java | 6 +++++- .../com/facebook/react/uimanager/TouchTargetHelper.java | 6 +++--- .../facebook/react/uimanager/events/PointerEventHelper.java | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.java index 88ab9e9efc0a7d..9532bcb7a07b01 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.java @@ -250,10 +250,14 @@ public void handleMotionEvent(MotionEvent motionEvent, EventDispatcher eventDisp case MotionEvent.ACTION_CANCEL: dispatchCancelEvent(eventState, motionEvent, eventDispatcher); break; + case MotionEvent.ACTION_HOVER_ENTER: + case MotionEvent.ACTION_HOVER_EXIT: + // These are handled by HOVER_MOVE + break; default: FLog.w( ReactConstants.TAG, - "Warning : Motion Event was ignored. Action=" + action + " Target=" + activeTargetTag); + "Motion Event was ignored. Action=" + action + " Target=" + activeTargetTag); return; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.java index f0d7c6fd335843..4b1a518f10dd7b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.java @@ -140,7 +140,7 @@ public static List findTargetPathAndCoordinatesForTouch( pathAccumulator = pathAccumulator.subList(firstReactAncestor, pathAccumulator.size()); } - int targetTag = getTouchTargetForView(reactTargetView, eventX, eventY); + int targetTag = getTouchTargetForView(reactTargetView, viewCoords[0], viewCoords[1]); if (targetTag != reactTargetView.getId()) { pathAccumulator.add(0, new ViewTarget(targetTag, (View) null)); } @@ -396,11 +396,11 @@ && isTouchPointInView(eventCoords[0], eventCoords[1], view) } } - private static int getTouchTargetForView(View targetView, float eventX, float eventY) { + private static int getTouchTargetForView(View targetView, float viewX, float viewY) { if (targetView instanceof ReactCompoundView) { // Use coordinates relative to the view, which have been already computed by // {@link #findTouchTargetView()}. - return ((ReactCompoundView) targetView).reactTagForTouch(eventX, eventY); + return ((ReactCompoundView) targetView).reactTagForTouch(viewX, viewY); } return targetView.getId(); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/PointerEventHelper.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/PointerEventHelper.java index 48408d7bcb5254..b4fdb4c37d09f4 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/PointerEventHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/PointerEventHelper.java @@ -115,7 +115,7 @@ public static String getW3CPointerType(final int toolType) { public static boolean isListening(@Nullable View view, EVENT event) { if (view == null) { - return false; + return true; } switch (event) {