Skip to content

Added accessibility prop to TextField's right button #876

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export default class InputsScreen extends Component {
containerStyle={{marginBottom: INPUT_SPACING}}
floatingPlaceholder
placeholder="With right button"
rightButtonProps={{iconSource: richText, onPress: this.onPressInfo}}
rightButtonProps={{iconSource: richText, onPress: this.onPressInfo, accessibilityLabel: 'TextField Info'}}
/>

<TextField
Expand Down
10 changes: 7 additions & 3 deletions src/components/inputs/TextField.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ export default class TextField extends BaseInput {
iconSource: RNImage.propTypes.source,
iconColor: PropTypes.string,
onPress: PropTypes.func,
style: PropTypes.oneOfType([PropTypes.object, PropTypes.number])
style: PropTypes.oneOfType([PropTypes.object, PropTypes.number]),
accessibilityLabel: PropTypes.string
}),
/**
* Pass to render a leading icon to the TextInput value. Accepts Image props (doesn't work with floatingPlaceholder)
Expand Down Expand Up @@ -606,10 +607,13 @@ export default class TextField extends BaseInput {
renderRightButton() {
if (this.shouldDisplayRightButton()) {
const {rightButtonProps} = this.getThemeProps();
const {style, iconSource, iconColor} = rightButtonProps;
const {style, iconSource, iconColor, accessibilityLabel, ...others} = rightButtonProps;

return (
<TouchableOpacity style={[this.styles.rightButton, style]} onPress={this.onPressRightButton}>
<TouchableOpacity
{...others} accessibilityLabel={accessibilityLabel}
style={[this.styles.rightButton, style]} onPress={this.onPressRightButton}
>
<Image
pointerEvents="none"
source={iconSource}
Expand Down