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
This commit is contained in:
Nicola Corti
2023-07-17 05:37:38 -07:00
committed by Facebook GitHub Bot
parent e21c25eb91
commit 995bb3e995
@@ -145,7 +145,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
@@ -162,6 +161,12 @@ import java.util.Set;
Map viewManagerDirectEvents = viewManager.getExportedCustomDirectEventTypeConstants();
validateDirectEventNames(viewManager.getName(), viewManagerDirectEvents);
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);