From 0f48e86fedc5269f6fa5112d40282b747eacc0de Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Wed, 26 Jul 2023 00:49:08 -0700 Subject: [PATCH] Return NONE accessibility role if `null` is passed. (#38613) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/38613 The `value` string of the ReactAccessibilityDelegate's `fromValue` method is marked as `Nullable`, however the `null` case is not handled. This change handle the `null` case setting the accesssibility role to NONE. ## Changelog: [Android][Fixed] - Set the accessibility role to `NONE` when a `null` string is passed to `fromValue` Reviewed By: cortinico Differential Revision: D47752098 fbshipit-source-id: e8a44bdd8874e996d8127cb2ee29e5135210b196 --- .../facebook/react/uimanager/ReactAccessibilityDelegate.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java index b8b08c9bf74e8c..eed04a1c711f7f 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.java @@ -295,6 +295,10 @@ public static String getValue(AccessibilityRole role) { } public static AccessibilityRole fromValue(@Nullable String value) { + if (value == null) { + return NONE; + } + for (AccessibilityRole role : AccessibilityRole.values()) { if (role.name().equalsIgnoreCase(value)) { return role;