Skip to content

Commit

Permalink
Merge pull request #26 from OLIOEX/add-accessibility-labels
Browse files Browse the repository at this point in the history
Add Accessibility Label to PhoneInput
  • Loading branch information
rililive authored Nov 4, 2021
2 parents 946c7c4 + 5e88c98 commit ce1b2a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/PhoneInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class PhoneInput<TextComponentType extends React.ComponentType =
} = this.props;

const {
countriesList, disabled,
countriesList, disabled
} = this.props;

if (countriesList) {
Expand Down Expand Up @@ -205,6 +205,10 @@ export default class PhoneInput<TextComponentType extends React.ComponentType =
: number;
}

getAccessibilityLabel() {
return this.props.accessibilityLabel || 'Telephone input';
}

focus() {
this.inputPhone.focus();
}
Expand Down Expand Up @@ -236,6 +240,7 @@ export default class PhoneInput<TextComponentType extends React.ComponentType =
ref={(ref) => {
this.inputPhone = ref;
}}
accessibilityLabel={this.getAccessibilityLabel()}
editable={!disabled}
autoCorrect={false}
style={[styles.text, this.props.textStyle]}
Expand Down
4 changes: 4 additions & 0 deletions src/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ export interface ReactNativeCountryPickerState {
}

export interface ReactNativePhoneInputProps<TextComponentType extends React.ComponentType = typeof TextInput> {
/**
* Override accessibility label for telephone input
*/
accessibilityLabel?: string;
/**
* Format input while typing
*/
Expand Down

0 comments on commit ce1b2a5

Please sign in to comment.