Provide ReactContext to experimental JSTouchDispatcher method (#53003)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53003

The new `onChildStartedNativeGesture` method accepts a nullable `ReactContext` value for the purpose of flushing active touch events. This change updates all callsites of that method to pass a `ReactContext`

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D79258727

fbshipit-source-id: 7b2950f514295dbe26822442c98079b8121cb3bf
This commit is contained in:
Peter Abbondanzo authored and Facebook GitHub Bot committed 2025-08-05 09:42:36 -07:00
1 parent 551af31871
commit 0f0a3cfce2
2 files changed
+10 -3

No files matched your search

@@ -205,10 +205,15 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
return;
}
@Nullable ReactContext reactContext = getCurrentReactContext();
if (reactContext == null) {
return;
}
EventDispatcher eventDispatcher =
UIManagerHelper.getEventDispatcher(getCurrentReactContext(), getUIManagerType());
UIManagerHelper.getEventDispatcher(reactContext, getUIManagerType());
if (eventDispatcher != null) {
mJSTouchDispatcher.onChildStartedNativeGesture(ev, eventDispatcher);
mJSTouchDispatcher.onChildStartedNativeGesture(ev, eventDispatcher, reactContext);
if (childView != null && mJSPointerDispatcher != null) {
mJSPointerDispatcher.onChildStartedNativeGesture(childView, ev, eventDispatcher);
}
@@ -37,6 +37,7 @@ import com.facebook.react.bridge.ReactContext
import com.facebook.react.bridge.UiThreadUtil
import com.facebook.react.bridge.WritableMap
import com.facebook.react.bridge.WritableNativeMap
import com.facebook.react.common.annotations.UnstableReactNativeAPI
import com.facebook.react.common.annotations.VisibleForTesting
import com.facebook.react.common.build.ReactBuildConfig
import com.facebook.react.config.ReactFeatureFlags
@@ -619,9 +620,10 @@ public class ReactModalHostView(context: ThemedReactContext) :
return super.onHoverEvent(event)
}
@OptIn(UnstableReactNativeAPI::class)
override fun onChildStartedNativeGesture(childView: View?, ev: MotionEvent) {
eventDispatcher?.let { eventDispatcher ->
jSTouchDispatcher.onChildStartedNativeGesture(ev, eventDispatcher)
jSTouchDispatcher.onChildStartedNativeGesture(ev, eventDispatcher, reactContext)
jSPointerDispatcher?.onChildStartedNativeGesture(childView, ev, eventDispatcher)
}
}