From d01831ae44b0f625d97050ca9d09c24ce0bf4bb9 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Tue, 12 Mar 2024 04:13:42 -0700 Subject: [PATCH] Apply pointerEvents dispatch check in dispatchGenericMotionEvent (#43433) Summary: Changelog: [Android][Fixed] Views would still receive hover events when nested in a view with pointer-events: "none" `View` calls `dispatchGenericPointerEvent` from `dispatchGenericMotionEvent` (https://android.googlesource.com/platform/frameworks/base/+/android-4.3_r2.1/core/java/android/view/View.java#7439), so this is the better method to override. Differential Revision: D54799820 --- .../react/views/scroll/ReactHorizontalScrollView.java | 6 +++--- .../com/facebook/react/views/scroll/ReactScrollView.java | 6 +++--- .../java/com/facebook/react/views/view/ReactViewGroup.java | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java index 7dbcb788c3ac..7e52edb5a2c7 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java @@ -640,13 +640,13 @@ public boolean onTouchEvent(MotionEvent ev) { } @Override - public boolean dispatchGenericPointerEvent(MotionEvent ev) { - // We do not dispatch the pointer event if its children are not supposed to receive it + public boolean dispatchGenericMotionEvent(MotionEvent ev) { + // We do not dispatch the motion event if its children are not supposed to receive it if (!PointerEvents.canChildrenBeTouchTarget(mPointerEvents)) { return false; } - return super.dispatchGenericPointerEvent(ev); + return super.dispatchGenericMotionEvent(ev); } @Override diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java index 49f7326f0a22..50fc9b0bc43c 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java @@ -463,13 +463,13 @@ public boolean onTouchEvent(MotionEvent ev) { } @Override - public boolean dispatchGenericPointerEvent(MotionEvent ev) { - // We do not dispatch the pointer event if its children are not supposed to receive it + public boolean dispatchGenericMotionEvent(MotionEvent ev) { + // We do not dispatch the motion event if its children are not supposed to receive it if (!PointerEvents.canChildrenBeTouchTarget(mPointerEvents)) { return false; } - return super.dispatchGenericPointerEvent(ev); + return super.dispatchGenericMotionEvent(ev); } @Override diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java index af5dea7170d4..bc5d22b34cc2 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java @@ -284,13 +284,13 @@ public boolean onTouchEvent(MotionEvent ev) { } @Override - public boolean dispatchGenericPointerEvent(MotionEvent ev) { - // We do not dispatch the pointer event if its children are not supposed to receive it + public boolean dispatchGenericMotionEvent(MotionEvent ev) { + // We do not dispatch the motion event if its children are not supposed to receive it if (!PointerEvents.canChildrenBeTouchTarget(mPointerEvents)) { return false; } - return super.dispatchGenericPointerEvent(ev); + return super.dispatchGenericMotionEvent(ev); } /**