Skip to content

Commit

Permalink
Apply pointerEvents dispatch check in dispatchGenericMotionEvent (fac…
Browse files Browse the repository at this point in the history
…ebook#43433)

Summary:
Pull Request resolved: facebook#43433

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.

Reviewed By: markv

Differential Revision: D54799820

fbshipit-source-id: 896572b86a0e9053b0138a18ced938a9dc3e60fc
  • Loading branch information
javache authored and facebook-github-bot committed Mar 13, 2024
1 parent 4f10f30 commit 38cbc08
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -6278,7 +6278,7 @@ public class com/facebook/react/views/scroll/ReactHorizontalScrollView : android
public fun addFocusables (Ljava/util/ArrayList;II)V
public fun arrowScroll (I)Z
public fun canScrollHorizontally (I)Z
public fun dispatchGenericPointerEvent (Landroid/view/MotionEvent;)Z
public fun dispatchGenericMotionEvent (Landroid/view/MotionEvent;)Z
public fun draw (Landroid/graphics/Canvas;)V
public fun executeKeyEvent (Landroid/view/KeyEvent;)Z
public fun flashScrollIndicators ()V
Expand Down Expand Up @@ -6404,7 +6404,7 @@ public class com/facebook/react/views/scroll/ReactScrollView : android/widget/Sc
public fun <init> (Landroid/content/Context;)V
public fun <init> (Landroid/content/Context;Lcom/facebook/react/views/scroll/FpsListener;)V
public fun abortAnimation ()V
public fun dispatchGenericPointerEvent (Landroid/view/MotionEvent;)Z
public fun dispatchGenericMotionEvent (Landroid/view/MotionEvent;)Z
public fun draw (Landroid/graphics/Canvas;)V
public fun executeKeyEvent (Landroid/view/KeyEvent;)Z
public fun flashScrollIndicators ()V
Expand Down Expand Up @@ -7567,7 +7567,7 @@ public class com/facebook/react/views/view/ReactViewGroup : android/view/ViewGro
public fun addView (Landroid/view/View;ILandroid/view/ViewGroup$LayoutParams;)V
protected fun addViewInLayout (Landroid/view/View;ILandroid/view/ViewGroup$LayoutParams;Z)Z
protected fun dispatchDraw (Landroid/graphics/Canvas;)V
public fun dispatchGenericPointerEvent (Landroid/view/MotionEvent;)Z
public fun dispatchGenericMotionEvent (Landroid/view/MotionEvent;)Z
public fun dispatchProvideStructure (Landroid/view/ViewStructure;)V
protected fun dispatchSetPressed (Z)V
protected fun drawChild (Landroid/graphics/Canvas;Landroid/view/View;J)Z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 38cbc08

Please sign in to comment.