From 7aed30a03700fa11844125bee4912c3de576800c Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Mon, 17 Jul 2023 05:37:38 -0700 Subject: [PATCH] Fabric Interop - Also normalize direct events (#38352) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/38352 This change is making sure we normalize both bubbling and direct events for the sake of Fabric Interop. This is currently required as some libraries have reported incompatiblities with Fabric Interop (see https://github.com/react-native-maps/react-native-maps/issues/4383) Also this is has been reported by the WG here: https://github.com/reactwg/react-native-new-architecture/discussions/135#discussioncomment-6443294 Changelog: [Android] [Fixed] - Fabric Interop - Fix support for direct events on Paper components Reviewed By: rshest Differential Revision: D47472050 fbshipit-source-id: f0ae95cb782e340281928819a702273fb14e9b16 --- .../react/uimanager/UIManagerModuleConstantsHelper.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelper.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelper.java index a570c7acdf0..663be21993e 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelper.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstantsHelper.java @@ -117,7 +117,6 @@ import java.util.Set; Map viewManagerBubblingEvents = viewManager.getExportedCustomBubblingEventTypeConstants(); if (viewManagerBubblingEvents != null) { - if (ReactFeatureFlags.enableFabricRenderer && ReactFeatureFlags.unstable_useFabricInterop) { // For Fabric, events needs to be fired with a "top" prefix. // For the sake of Fabric Interop, here we normalize events adding "top" in their @@ -133,6 +132,12 @@ import java.util.Set; Map viewManagerDirectEvents = viewManager.getExportedCustomDirectEventTypeConstants(); if (viewManagerDirectEvents != null) { + if (ReactFeatureFlags.enableFabricRenderer && ReactFeatureFlags.unstable_useFabricInterop) { + // For Fabric, events needs to be fired with a "top" prefix. + // For the sake of Fabric Interop, here we normalize events adding "top" in their + // name if the user hasn't provided it. + normalizeEventTypes(viewManagerDirectEvents); + } recursiveMerge(cumulativeDirectEventTypes, viewManagerDirectEvents); recursiveMerge(viewManagerDirectEvents, defaultDirectEvents); viewManagerConstants.put(DIRECT_EVENTS_KEY, viewManagerDirectEvents);