Skip to content

Commit 0f0a3cf

Browse files
Abbondanzofacebook-github-bot
authored andcommitted
Provide ReactContext to experimental JSTouchDispatcher method (#53003)
Summary: Pull Request resolved: #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
1 parent 551af31 commit 0f0a3cf

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,15 @@ public void onChildStartedNativeGesture(View childView, MotionEvent ev) {
205205
return;
206206
}
207207

208+
@Nullable ReactContext reactContext = getCurrentReactContext();
209+
if (reactContext == null) {
210+
return;
211+
}
212+
208213
EventDispatcher eventDispatcher =
209-
UIManagerHelper.getEventDispatcher(getCurrentReactContext(), getUIManagerType());
214+
UIManagerHelper.getEventDispatcher(reactContext, getUIManagerType());
210215
if (eventDispatcher != null) {
211-
mJSTouchDispatcher.onChildStartedNativeGesture(ev, eventDispatcher);
216+
mJSTouchDispatcher.onChildStartedNativeGesture(ev, eventDispatcher, reactContext);
212217
if (childView != null && mJSPointerDispatcher != null) {
213218
mJSPointerDispatcher.onChildStartedNativeGesture(childView, ev, eventDispatcher);
214219
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import com.facebook.react.bridge.ReactContext
3737
import com.facebook.react.bridge.UiThreadUtil
3838
import com.facebook.react.bridge.WritableMap
3939
import com.facebook.react.bridge.WritableNativeMap
40+
import com.facebook.react.common.annotations.UnstableReactNativeAPI
4041
import com.facebook.react.common.annotations.VisibleForTesting
4142
import com.facebook.react.common.build.ReactBuildConfig
4243
import com.facebook.react.config.ReactFeatureFlags
@@ -619,9 +620,10 @@ public class ReactModalHostView(context: ThemedReactContext) :
619620
return super.onHoverEvent(event)
620621
}
621622

623+
@OptIn(UnstableReactNativeAPI::class)
622624
override fun onChildStartedNativeGesture(childView: View?, ev: MotionEvent) {
623625
eventDispatcher?.let { eventDispatcher ->
624-
jSTouchDispatcher.onChildStartedNativeGesture(ev, eventDispatcher)
626+
jSTouchDispatcher.onChildStartedNativeGesture(ev, eventDispatcher, reactContext)
625627
jSPointerDispatcher?.onChildStartedNativeGesture(childView, ev, eventDispatcher)
626628
}
627629
}

0 commit comments

Comments
 (0)