From 06c295c58fe5449ecbf69bfb52bb8e52cd64308b Mon Sep 17 00:00:00 2001 From: Carmen Krol Date: Mon, 9 Oct 2023 13:51:09 -0700 Subject: [PATCH] Support grouped focus for switch (#40739) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/40739 Adding support for grouped accessibility focus on switch. This is when the switch itself shouldn't be directly focusable. Instead, the parent element should be focusable, including announcing the switch role and state changes, e.g. "on" and "off". Fix this issue in a couple ways: 1. Make sure to set the proper role for switch in FbReactSwitchCompat.java. 2. Set the state description in SwitchCompat.java so that uses the correct announcement of "off" and "on" instead of "checked" and "unchecked". Reviewed By: blavalla Differential Revision: D50068169 fbshipit-source-id: 0c4133377f7a29da9cadb730399bdbedd58c26ae --- .../facebook/react/uimanager/ReactAccessibilityDelegate.java | 5 ----- 1 file changed, 5 deletions(-) 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 0e0bd71b68173f..2152d87657c470 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 @@ -629,11 +629,6 @@ private static void setState( final boolean boolValue = value.asBoolean(); info.setCheckable(true); info.setChecked(boolValue); - if (info.getClassName().equals(AccessibilityRole.getValue(AccessibilityRole.SWITCH))) { - info.setStateDescription( - context.getString( - boolValue ? R.string.state_on_description : R.string.state_off_description)); - } } } }