From 006527fea70e0d1ef64eee05c7ee9f98dfda8a4d Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Fri, 9 Dec 2022 03:47:28 -0800 Subject: [PATCH] Fix onAccessibilityAction on Fabric (#35507) Summary: fixes https://github.com/facebook/react-native/issues/30841#issuecomment-1228128357. onAccessibilityAction does not work on Fabric and logs: ``` E/unknown:ReactEventEmitter( 3845): com.facebook.react.bridge.ReactNoCrashSoftException: Cannot find EventEmitter for receiveEvent: SurfaceId[1] ReactTag[104] UIManagerType[2] ``` ## Changelog [Android] [Fixed] - Fix onAccessibilityAction on Fabric Pull Request resolved: https://github.com/facebook/react-native/pull/35507 Test Plan: https://github.com/facebook/react-native/pull/35507#issuecomment-1330876598 Reviewed By: javache Differential Revision: D41707777 Pulled By: philIip fbshipit-source-id: 0f4550a17f4b8bfc1aefa404059b367907f8f60d --- .../facebook/react/uimanager/ReactAccessibilityDelegate.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java index 6afb3c4ced7e27..626232ed0f3998 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java @@ -45,6 +45,7 @@ import com.facebook.react.bridge.UIManager; import com.facebook.react.bridge.WritableMap; import com.facebook.react.uimanager.ReactAccessibilityDelegate.AccessibilityRole; +import com.facebook.react.uimanager.common.ViewUtil; import com.facebook.react.uimanager.events.Event; import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.react.uimanager.util.ReactFindViewUtil; @@ -420,7 +421,8 @@ public boolean performAccessibilityAction(View host, int action, Bundle args) { if (reactContext.hasActiveReactInstance()) { final int reactTag = host.getId(); final int surfaceId = UIManagerHelper.getSurfaceId(reactContext); - UIManager uiManager = UIManagerHelper.getUIManager(reactContext, reactTag); + UIManager uiManager = + UIManagerHelper.getUIManager(reactContext, ViewUtil.getUIManagerType(reactTag)); if (uiManager != null) { uiManager .getEventDispatcher()