Skip to content
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
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export interface PickerSelectProps {
useNativeAndroidPickerStyle?: boolean;
fixAndroidTouchableBug?: boolean;
doneText?: string;
dismissText?: string;
onDonePress?: () => void;
onUpArrow?: () => void;
onDownArrow?: () => void;
Expand Down
7 changes: 6 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default class RNPickerSelect extends PureComponent {

// Custom Modal props (iOS only)
doneText: PropTypes.string,
dismissText: PropTypes.string,
onDonePress: PropTypes.func,
onUpArrow: PropTypes.func,
onDownArrow: PropTypes.func,
Expand Down Expand Up @@ -98,6 +99,7 @@ export default class RNPickerSelect extends PureComponent {
useNativeAndroidPickerStyle: true,
fixAndroidTouchableBug: false,
doneText: 'Done',
dismissText: 'Dismiss',
onDonePress: null,
onUpArrow: null,
onDownArrow: null,
Expand Down Expand Up @@ -510,7 +512,8 @@ export default class RNPickerSelect extends PureComponent {
}

renderIOS() {
const { disabled, style, modalProps, pickerProps, touchableWrapperProps } = this.props;
const { disabled, style, modalProps, pickerProps, touchableWrapperProps, dismissText } =
this.props;
const { animationType, orientation, selectedItem, showPicker } = this.state;

const accessibilityLabel = pickerProps && pickerProps.accessibilityLabel;
Expand Down Expand Up @@ -558,6 +561,8 @@ export default class RNPickerSelect extends PureComponent {
onPress={() => {
this.togglePicker(true);
}}
accessibilityRole="button"
accessibilityLabel={dismissText}
/>
{this.renderInputAccessoryView()}
<View
Expand Down
25 changes: 25 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,31 @@ describe("RNPickerSelect", () => {

expect(doneButton.props().accessibilityLabel).toEqual("Confirm");
});

it("should announce the dismiss overlay as a button labeled Dismiss by default (iOS)", () => {
const wrapper = shallow(
<RNPickerSelect items={selectItems} onValueChange={noop} />,
);

const dismissOverlay = wrapper.find('[testID="ios_modal_top"]');

expect(dismissOverlay.props().accessibilityRole).toEqual("button");
expect(dismissOverlay.props().accessibilityLabel).toEqual("Dismiss");
});

it("should use custom dismissText as accessibilityLabel on the dismiss overlay (iOS)", () => {
const wrapper = shallow(
<RNPickerSelect
items={selectItems}
onValueChange={noop}
dismissText="Close"
/>,
);

const dismissOverlay = wrapper.find('[testID="ios_modal_top"]');

expect(dismissOverlay.props().accessibilityLabel).toEqual("Close");
});
});

it("should call the onClose callback when set", () => {
Expand Down
Loading