@@ -119,6 +119,16 @@ export default class TabBarBottom extends React.Component<Props, State> {
119
119
} ) ;
120
120
} ;
121
121
122
+ private getLabelText = ( { route } : { route : Route < string > } ) => {
123
+ const { options } = this . props . descriptors [ route . key ] ;
124
+
125
+ return options . tabBarLabel !== undefined
126
+ ? options . tabBarLabel
127
+ : options . title !== undefined
128
+ ? options . title
129
+ : route . name ;
130
+ } ;
131
+
122
132
private renderLabel = ( {
123
133
route,
124
134
focused,
@@ -139,14 +149,7 @@ export default class TabBarBottom extends React.Component<Props, State> {
139
149
return null ;
140
150
}
141
151
142
- const { options } = this . props . descriptors [ route . key ] ;
143
- const label =
144
- options . tabBarLabel !== undefined
145
- ? options . tabBarLabel
146
- : options . title !== undefined
147
- ? options . title
148
- : route . name ;
149
-
152
+ const label = this . getLabelText ( { route } ) ;
150
153
const horizontal = this . shouldUseHorizontalLabels ( ) ;
151
154
const color = focused ? activeTintColor : inactiveTintColor ;
152
155
@@ -354,6 +357,14 @@ export default class TabBarBottom extends React.Component<Props, State> {
354
357
} ) ;
355
358
} ;
356
359
360
+ const label = this . getLabelText ( { route } ) ;
361
+ const accessibilityLabel =
362
+ options . tabBarAccessibilityLabel !== undefined
363
+ ? options . tabBarAccessibilityLabel
364
+ : typeof label === 'string'
365
+ ? `${ label } , tab, ${ index + 1 } of ${ routes . length } `
366
+ : undefined ;
367
+
357
368
return (
358
369
< NavigationContext . Provider
359
370
key = { route . key }
@@ -362,10 +373,10 @@ export default class TabBarBottom extends React.Component<Props, State> {
362
373
{ renderButton ( {
363
374
onPress,
364
375
onLongPress,
365
- testID : options . tabBarTestID ,
366
- accessibilityLabel : options . tabBarAccessibilityLabel ,
376
+ accessibilityLabel,
367
377
accessibilityRole : 'button' ,
368
378
accessibilityStates : focused ? [ 'selected' ] : [ ] ,
379
+ testID : options . tabBarTestID ,
369
380
style : [
370
381
styles . tab ,
371
382
{ backgroundColor } ,
0 commit comments