From 3c7918dfbe044f2e0cb0c22153a6a37203b35f8b Mon Sep 17 00:00:00 2001 From: "satyajit.happy" Date: Wed, 10 Apr 2019 12:30:57 +0200 Subject: [PATCH] fix: specify default values for getAccessibilityX fixes #116 --- .../src/navigators/createBottomTabNavigator.js | 2 ++ packages/bottom-tabs/src/views/BottomTabBar.js | 13 ++++--------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/bottom-tabs/src/navigators/createBottomTabNavigator.js b/packages/bottom-tabs/src/navigators/createBottomTabNavigator.js index 934cd8bfc27787..adf180faa03929 100644 --- a/packages/bottom-tabs/src/navigators/createBottomTabNavigator.js +++ b/packages/bottom-tabs/src/navigators/createBottomTabNavigator.js @@ -27,6 +27,8 @@ type State = { class TabNavigationView extends React.PureComponent { static defaultProps = { lazy: true, + getAccessibilityRole: () => 'button', + getAccessibilityStates: ({ focused }) => (focused ? ['selected'] : []), }; static getDerivedStateFromProps(nextProps, prevState) { diff --git a/packages/bottom-tabs/src/views/BottomTabBar.js b/packages/bottom-tabs/src/views/BottomTabBar.js index 08b579f29ea8b3..c8a94c426bfc91 100644 --- a/packages/bottom-tabs/src/views/BottomTabBar.js +++ b/packages/bottom-tabs/src/views/BottomTabBar.js @@ -356,18 +356,13 @@ class TabBarBottom extends React.Component { route, }); - const accessibilityRole = - this.props.getAccessibilityRole({ - route, - }) || 'button'; - - let accessibilityStates = this.props.getAccessibilityStates({ + const accessibilityRole = this.props.getAccessibilityRole({ route, }); - if (!accessibilityStates) { - accessibilityStates = focused ? ['selected'] : []; - } + const accessibilityStates = this.props.getAccessibilityStates( + scene + ); const testID = this.props.getTestID({ route });