fix: add accessibilityState property (#8548)

React Native 0.62 removes the deprecated `accessibilityStates` property and replaces it with an `accessibilityState` object instead. This PR adds the new property where needed, but leaves the old one in place for backwards compatibility. Without the change, the selected tab in BottomTabNavigator isn't announced properly in VoiceOver.
This commit is contained in:
Simon Arm-Riding
2020-07-28 10:28:42 +01:00
committed by GitHub
parent baea77e332
commit ce4eb7e927
2 changed files with 2 additions and 0 deletions

View File

@@ -258,6 +258,7 @@ export default function BottomTabBarItem({
testID,
accessibilityLabel,
accessibilityRole: 'button',
accessibilityState: { selected: focused },
accessibilityStates: focused ? ['selected'] : [],
style: [
styles.tab,

View File

@@ -156,6 +156,7 @@ export default function DrawerItem(props: Props) {
accessibilityTraits={focused ? ['button', 'selected'] : 'button'}
accessibilityComponentType="button"
accessibilityRole="button"
accessibilityState={{ selected: focused }}
accessibilityStates={focused ? ['selected'] : []}
to={to}
>