Skip to content

Commit 2efb25f

Browse files
authored
Merge pull request #190 from hakuna/tab-accessibility-labels
Add accessible and accessibilityLabel props for testability
2 parents 9540e5d + d101321 commit 2efb25f

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,6 @@ TabNavigator.Item props
9191
| selected | none | boolean | return whether the item is selected |
9292
| onPress | none | function | onPress method for Item |
9393
| allowFontScaling | false | boolean | allow font scaling for title |
94-
95-
94+
| accessible | none | boolean | indicates if this item is an accessibility element |
95+
| accessibilityLabel | none | string | override text for screen readers |
96+
| testID | none | string | used to locate this item in end-to-end-tests |

Tab.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import Layout from './Layout';
1717
export default class Tab extends React.Component {
1818
static propTypes = {
1919
testID : PropTypes.string,
20+
accessible: PropTypes.bool,
21+
accessibilityLabel : PropTypes.string,
2022
title: PropTypes.string,
2123
titleStyle: Text.propTypes.style,
2224
badge: PropTypes.element,
@@ -68,6 +70,8 @@ export default class Tab extends React.Component {
6870
return (
6971
<TouchableNativeFeedback
7072
testID={this.props.testID}
73+
accessible={this.props.accessible}
74+
accessibilityLabel={this.props.accessibilityLabel}
7175
background={TouchableNativeFeedback.Ripple(undefined, true)}
7276
onPress={this._handlePress}>
7377
<View style={tabStyle}>
@@ -83,6 +87,8 @@ export default class Tab extends React.Component {
8387
return (
8488
<TouchableOpacity
8589
testID={this.props.testID}
90+
accessible={this.props.accessible}
91+
accessibilityLabel={this.props.accessibilityLabel}
8692
activeOpacity={this.props.hidesTabTouch ? 1.0 : 0.8}
8793
onPress={this._handlePress}
8894
style={tabStyle}>

TabNavigator.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ export default class TabNavigator extends React.Component {
122122
return (
123123
<Tab
124124
testID={item.props.testID}
125+
accessible={item.props.accessible}
126+
accessibilityLabel={item.props.accessibilityLabel}
125127
title={item.props.title}
126128
allowFontScaling={item.props.allowFontScaling}
127129
titleStyle={[

0 commit comments

Comments
 (0)