Skip to content

Commit b8926f3

Browse files
authored
Added accessibility prop to TextField's right button (#876)
* add accessibility prop to TextField's right button * Use ...others- spread and passing directly the accessibilityLabel
1 parent 1e1bb1f commit b8926f3

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

demo/src/screens/componentScreens/TextFieldScreen/InputsScreen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export default class InputsScreen extends Component {
216216
containerStyle={{marginBottom: INPUT_SPACING}}
217217
floatingPlaceholder
218218
placeholder="With right button"
219-
rightButtonProps={{iconSource: richText, onPress: this.onPressInfo}}
219+
rightButtonProps={{iconSource: richText, onPress: this.onPressInfo, accessibilityLabel: 'TextField Info'}}
220220
/>
221221

222222
<TextField

src/components/inputs/TextField.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ export default class TextField extends BaseInput {
171171
iconSource: RNImage.propTypes.source,
172172
iconColor: PropTypes.string,
173173
onPress: PropTypes.func,
174-
style: PropTypes.oneOfType([PropTypes.object, PropTypes.number])
174+
style: PropTypes.oneOfType([PropTypes.object, PropTypes.number]),
175+
accessibilityLabel: PropTypes.string
175176
}),
176177
/**
177178
* Pass to render a leading icon to the TextInput value. Accepts Image props (doesn't work with floatingPlaceholder)
@@ -606,10 +607,13 @@ export default class TextField extends BaseInput {
606607
renderRightButton() {
607608
if (this.shouldDisplayRightButton()) {
608609
const {rightButtonProps} = this.getThemeProps();
609-
const {style, iconSource, iconColor} = rightButtonProps;
610+
const {style, iconSource, iconColor, accessibilityLabel, ...others} = rightButtonProps;
610611

611612
return (
612-
<TouchableOpacity style={[this.styles.rightButton, style]} onPress={this.onPressRightButton}>
613+
<TouchableOpacity
614+
{...others} accessibilityLabel={accessibilityLabel}
615+
style={[this.styles.rightButton, style]} onPress={this.onPressRightButton}
616+
>
613617
<Image
614618
pointerEvents="none"
615619
source={iconSource}

0 commit comments

Comments
 (0)