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 1 commit
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
5 changes: 3 additions & 2 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 @@ -609,7 +610,7 @@ export default class TextField extends BaseInput {
const {style, iconSource, iconColor} = rightButtonProps;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of passing all the props included in rightButtonProps, pass on the "rest" of the props that were not used specifically.

const {style, iconSource, iconColor, ...others} = rightButtonProps;
<TouchableOpacity {...others} style={[this.styles.rightButton, style]} onPress={this.onPressRightButton}>


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