mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Mark HoverEvents as handled when pointer event dispatching is enabled (#46445)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46445 Similarly to onTouchEvent, we should return true from onHoverEvent to signal to Android that the hover event is "handled" (because we've dispatched the event to JS). This is important to be able to distinguish multiple stacked React roots on top of each other. Changelog: [Android][Fixed] Hover events were dispatched incorrectly when multiple ReactRoots were layered. Reviewed By: mdvacca Differential Revision: D62529586 fbshipit-source-id: d007c44b8ef56989888eb9a993e1428bd0b72a7b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c942469700
commit
533ef2ca37
@@ -8279,6 +8279,7 @@ public class com/facebook/react/views/view/ReactViewGroup : android/view/ViewGro
|
||||
public fun getZIndexMappedChildIndex (I)I
|
||||
public fun hasOverlappingRendering ()Z
|
||||
protected fun onAttachedToWindow ()V
|
||||
public fun onHoverEvent (Landroid/view/MotionEvent;)Z
|
||||
public fun onInterceptTouchEvent (Landroid/view/MotionEvent;)Z
|
||||
protected fun onLayout (ZIIII)V
|
||||
protected fun onMeasure (II)V
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ public class JSPointerDispatcher {
|
||||
private static final int UNSELECTED_VIEW_TAG = -1;
|
||||
private static final int UNSET_POINTER_ID = -1;
|
||||
private static final float ONMOVE_EPSILON = 0.1f;
|
||||
private static final String TAG = "POINTER EVENTS";
|
||||
private static final String TAG = "PointerEvents";
|
||||
|
||||
private Map<Integer, List<ViewTarget>> mLastHitPathByPointerId;
|
||||
private Map<Integer, float[]> mLastEventCoordinatesByPointerId;
|
||||
|
||||
+10
@@ -37,6 +37,7 @@ import com.facebook.react.bridge.ReactSoftExceptionLogger;
|
||||
import com.facebook.react.bridge.UiThreadUtil;
|
||||
import com.facebook.react.common.annotations.UnstableReactNativeAPI;
|
||||
import com.facebook.react.common.annotations.VisibleForTesting;
|
||||
import com.facebook.react.config.ReactFeatureFlags;
|
||||
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags;
|
||||
import com.facebook.react.modules.i18nmanager.I18nUtil;
|
||||
import com.facebook.react.touch.OnInterceptTouchEventListener;
|
||||
@@ -309,6 +310,15 @@ public class ReactViewGroup extends ViewGroup
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onHoverEvent(MotionEvent event) {
|
||||
if (ReactFeatureFlags.dispatchPointerEvents) {
|
||||
// Match the logic from onTouchEvent if pointer events are enabled
|
||||
return PointerEvents.canBeTouchTarget(mPointerEvents);
|
||||
}
|
||||
return super.onHoverEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchGenericMotionEvent(MotionEvent ev) {
|
||||
// We do not dispatch the motion event if its children are not supposed to receive it
|
||||
|
||||
Reference in New Issue
Block a user