Skip to content

Commit

Permalink
fix onAccessibilityAction not work on Fabric
Browse files Browse the repository at this point in the history
ReactAccessibilityDelegate performAccessibilityAction dispatches the event topAccessibilityAction
--
Understand why Fabric does not call registerEventEmitter before performAccessibilityAction for that reactTag/surfaceId
Read StackTrace from error message (use printStacktrace)
The method getUIManager retrieve the UIManager from the reactTag and does not check if is Fabric or Paper

ReactAccessibilityDelegate [performAccessibilityAction](https://github.com/facebook/react-native/blob/bf37a34c38b39a14de8194520d07de0b9f8c0bf7/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java#L410-L415) dispatches the event topAccessibilityAction
Understand why Fabric does not call [registerEventEmitter](https://github.com/fabriziobertoglio1987/react-native/blob/163171ccab6937785f4f3c85e011bd14540bebf5/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java#L426) before performAccessibilityAction for that reactTag/surfaceId
Read StackTrace from [error message](facebook#30841 (comment)) (use [printStacktrace](https://www.google.com/search?q=java+printStacktrace))
The method [getUIManager](https://github.com/fabriziobertoglio1987/react-native/blob/dc4c54ec1b7b7f7cd37c7402b1eac5292cb4996a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerHelper.java#L40-L48) retrieve the UIManager from the reactTag and does not check if is Fabric or Paper
  • Loading branch information
fabOnReact committed Nov 29, 2022
1 parent 1b99473 commit 69d43f8
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import com.facebook.react.bridge.ReadableType;
import com.facebook.react.bridge.UIManager;
import com.facebook.react.bridge.WritableMap;
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;
Expand Down Expand Up @@ -403,7 +404,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
.<EventDispatcher>getEventDispatcher()
Expand Down

0 comments on commit 69d43f8

Please sign in to comment.