From ac35fe06115bd39616275386a4d7dcc354f947d2 Mon Sep 17 00:00:00 2001 From: Vincent Riemer <1398555+vincentriemer@users.noreply.github.com> Date: Wed, 14 Aug 2024 15:30:14 -0700 Subject: [PATCH] fix erroneous pointerenter events firing when pointer leaves app bounds Summary: Changelog: [Internal] Differential Revision: D61298649 --- .../facebook/react/uimanager/JSPointerDispatcher.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.java index ef22bd280dd96c..eb50d4cf8592c3 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/JSPointerDispatcher.java @@ -294,14 +294,7 @@ public void handleMotionEvent( PointerEventState eventState = createEventState(activePointerId, motionEvent); - // We've empirically determined that when we get a ACTION_HOVER_EXIT from the root view on the - // `onInterceptHoverEvent`, this means we've exited the root view. - // This logic may be wrong but reasoning about the dispatch sequence for HOVER_ENTER/HOVER_EXIT - // doesn't follow the capture/bubbling sequence like other MotionEvents. See: - // https://developer.android.com/reference/android/view/MotionEvent#ACTION_HOVER_ENTER - // https://suragch.medium.com/how-touch-events-are-delivered-in-android-eee3b607b038 - boolean isExitFromRoot = - isCapture && motionEvent.getActionMasked() == MotionEvent.ACTION_HOVER_EXIT; + boolean isExitFromRoot = motionEvent.getActionMasked() == MotionEvent.ACTION_HOVER_EXIT; // Calculate the targetTag, with special handling for when we exit the root view. In that case, // we use the root viewId of the last event