Skip to content

Commit c715302

Browse files
fangmobilebestander
authored andcommitted
added accessibility props for touchables
Summary: accessibilityLabels are missing in these touchable*.js files. for #5322 ide This is not tested yet. I will update with test. Closes facebook/react-native#5346 Reviewed By: svcscm Differential Revision: D2882061 Pulled By: gkassabli fb-gh-sync-id: dff0ef373e5f5895027cb1cc08c8887a6ace8eee
1 parent 1ef0b8f commit c715302

9 files changed

Lines changed: 30 additions & 6 deletions

File tree

Examples/UIExplorer/TextInputExample.android.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,13 @@ exports.examples = [
208208
{
209209
title: 'Auto-focus',
210210
render: function() {
211-
return <TextInput autoFocus={true} style={styles.singleLine} />;
211+
return (
212+
<TextInput
213+
autoFocus={true}
214+
style={styles.singleLine}
215+
accessibilityLabel="I am the accessibility label for text input"
216+
/>
217+
);
212218
}
213219
},
214220
{

Examples/UIExplorer/TextInputExample.ios.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,13 @@ exports.examples = [
348348
{
349349
title: 'Auto-focus',
350350
render: function() {
351-
return <TextInput autoFocus={true} style={styles.default} />;
351+
return (
352+
<TextInput
353+
autoFocus={true}
354+
style={styles.default}
355+
accessibilityLabel="I am the accessibility label for text input"
356+
/>
357+
);
352358
}
353359
},
354360
{

Examples/UIExplorer/TouchableExample.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ var TouchableFeedbackEvents = React.createClass({
144144
<TouchableOpacity
145145
style={styles.wrapper}
146146
testID="touchable_feedback_events_button"
147+
accessibilityLabel="touchable feedback events"
148+
accessibilityTraits="button"
149+
accessibilityComponentType="button"
147150
onPress={() => this._appendEvent('press')}
148151
onPressIn={() => this._appendEvent('pressIn')}
149152
onPressOut={() => this._appendEvent('pressOut')}

Libraries/Components/TextInput/TextInput.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,6 @@ var TextInput = React.createClass({
290290
* Styles
291291
*/
292292
style: Text.propTypes.style,
293-
/**
294-
* Used to locate this view in end-to-end tests
295-
*/
296-
testID: PropTypes.string,
297293
/**
298294
* The color of the textInput underline.
299295
* @platform android
@@ -457,6 +453,9 @@ var TextInput = React.createClass({
457453
<TouchableWithoutFeedback
458454
onPress={this._onPress}
459455
rejectResponderTermination={true}
456+
accessible={props.accessible}
457+
accessibilityLabel={props.accessibilityLabel}
458+
accessibilityTraits={props.accessibilityTraits}
460459
testID={props.testID}>
461460
{textContainer}
462461
</TouchableWithoutFeedback>
@@ -520,6 +519,9 @@ var TextInput = React.createClass({
520519
return (
521520
<TouchableWithoutFeedback
522521
onPress={this._onPress}
522+
accessible={this.props.accessible}
523+
accessibilityLabel={this.props.accessibilityLabel}
524+
accessibilityComponentType={this.props.accessibilityComponentType}
523525
testID={this.props.testID}>
524526
{textContainer}
525527
</TouchableWithoutFeedback>

Libraries/Components/Touchable/TouchableBounce.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ var TouchableBounce = React.createClass({
117117
<Animated.View
118118
style={[{transform: [{scale: this.state.scale}]}, this.props.style]}
119119
accessible={true}
120+
accessibilityLabel={this.props.accessibilityLabel}
121+
accessibilityComponentType={this.props.accessibilityComponentType}
122+
accessibilityTraits={this.props.accessibilityTraits}
120123
testID={this.props.testID}
121124
onStartShouldSetResponder={this.touchableHandleStartShouldSetResponder}
122125
onResponderTerminationRequest={this.touchableHandleResponderTerminationRequest}

Libraries/Components/Touchable/TouchableHighlight.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ var TouchableHighlight = React.createClass({
215215
return (
216216
<View
217217
accessible={true}
218+
accessibilityLabel={this.props.accessibilityLabel}
218219
accessibilityComponentType={this.props.accessibilityComponentType}
219220
accessibilityTraits={this.props.accessibilityTraits}
220221
ref={UNDERLAY_REF}

Libraries/Components/Touchable/TouchableNativeFeedback.android.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ var TouchableNativeFeedback = React.createClass({
200200
...onlyChild(this.props.children).props,
201201
nativeBackgroundAndroid: this.props.background,
202202
accessible: this.props.accessible !== false,
203+
accessibilityLabel: this.props.accessibilityLabel,
203204
accessibilityComponentType: this.props.accessibilityComponentType,
204205
accessibilityTraits: this.props.accessibilityTraits,
205206
testID: this.props.testID,

Libraries/Components/Touchable/TouchableOpacity.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ var TouchableOpacity = React.createClass({
154154
return (
155155
<Animated.View
156156
accessible={true}
157+
accessibilityLabel={this.props.accessibilityLabel}
157158
accessibilityComponentType={this.props.accessibilityComponentType}
158159
accessibilityTraits={this.props.accessibilityTraits}
159160
style={[this.props.style, {opacity: this.state.anim}]}

Libraries/Components/Touchable/TouchableWithoutFeedback.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ var TouchableWithoutFeedback = React.createClass({
135135
// Note(avik): remove dynamic typecast once Flow has been upgraded
136136
return (React: any).cloneElement(onlyChild(this.props.children), {
137137
accessible: this.props.accessible !== false,
138+
accessibilityLabel: this.props.accessibilityLabel,
138139
accessibilityComponentType: this.props.accessibilityComponentType,
139140
accessibilityTraits: this.props.accessibilityTraits,
140141
testID: this.props.testID,

0 commit comments

Comments
 (0)