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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ export const Dropdown = () => {
| `Icon` | Custom icon component to be rendered.<br>_More details in [styling](#styling)_ | Component |
| `textInputProps` | Additional props to pass to the TextInput (some props are used in core functionality so use this carefully). This is iOS only unless `useNativeAndroidPickerStyle={false}`. | object |
| `touchableWrapperProps` | Additional props to pass to the touchable wrapping the TextInput (some props are used in core functionality so use this carefully) | object |
| `onOpen`<br> | Callback triggered right before the opening of the picker<br>_Not supported when `useNativeAndroidPickerStyle={true}`_ | function |
| `onOpen()`<br> | Callback triggered right before the opening of the picker<br>_Not supported when `useNativeAndroidPickerStyle={true}`_ | function |
| `useNativeAndroidPickerStyle`<br>_Android only_ | The component defaults to using the native Android Picker in its un-selected state. Setting this flag to `false` will mimic the default iOS presentation where a tappable TextInput is displayed.<br>_More details in [styling](#styling)_ | boolean |
| `fixAndroidTouchableBug`<br>_Android only_ | Experimental flag to fix issue [#354](https://github.com/lawnstarter/react-native-picker-select/issues/354) | boolean |
| `InputAccessoryView`<br>_iOS only_ | Replace the InputAcessoryView section (bar with tabbing arrown and Done button) of the opened picker with your own custom component. Can also return `null` here to hide completely. While this bar is typical on `select` elements on the web, the [interface guidelines](https://developer.apple.com/ios/human-interface-guidelines/controls/pickers/) does not include it. View the [snack](https://snack.expo.io/@lfkwtz/react-native-picker-select) to see examples on how this can be customized. | Component |
| `doneText`<br>_iOS only_ | "Done" default text on the modal. Can be overwritten here | string |
| `onUpArrow / onDownArrow`<br>_iOS only_ | Presence enables the corresponding arrow<br>- Closes the picker<br>- Calls the callback provided | function |
| `onDonePress`<br>_iOS only_ | Callback when the 'Done' button is pressed | function |
| `onClose`<br>_iOS only_ | Callback triggered right before the closing of the picker | function |
| `onUpArrow() / onDownArrow()`<br>_iOS only_ | Presence enables the corresponding arrow<br>- Closes the picker<br>- Calls the callback provided | function |
| `onDonePress()`<br>_iOS only_ | Callback when the 'Done' button is pressed | function |
| `onClose(Bool)`<br>_iOS only_ | Callback triggered right before the closing of the picker. It has one boolean parameter indicating if the done button was pressed or not | function |
| `modalProps`<br>_iOS only_ | Additional props to pass to the Modal (some props are used in core functionality so use this carefully) | object |
| `touchableDoneProps`<br>_iOS only_ | Additional props to pass to the Done touchable (some props are used in core functionality so use this carefully) | object |

Expand Down
10 changes: 5 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export default class RNPickerSelect extends PureComponent {
return Platform.OS === 'ios' && darkTheme;
}

triggerOpenCloseCallbacks() {
triggerOpenCloseCallbacks(donePressed) {
const { onOpen, onClose } = this.props;
const { showPicker } = this.state;

Expand All @@ -231,11 +231,11 @@ export default class RNPickerSelect extends PureComponent {
}

if (showPicker && onClose) {
onClose();
onClose(donePressed);
}
}

togglePicker(animate = false, postToggleCallback) {
togglePicker(animate = false, postToggleCallback, donePressed = false) {
const { modalProps, disabled } = this.props;
const { showPicker } = this.state;

Expand All @@ -250,7 +250,7 @@ export default class RNPickerSelect extends PureComponent {
const animationType =
modalProps && modalProps.animationType ? modalProps.animationType : 'slide';

this.triggerOpenCloseCallbacks();
this.triggerOpenCloseCallbacks(donePressed);

this.setState(
(prevState) => {
Expand Down Expand Up @@ -346,7 +346,7 @@ export default class RNPickerSelect extends PureComponent {
<TouchableOpacity
testID="done_button"
onPress={() => {
this.togglePicker(true, onDonePress);
this.togglePicker(true, onDonePress, true);
}}
onPressIn={() => {
this.setState({ doneDepressed: true });
Expand Down
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ describe('RNPickerSelect', () => {
// Close
touchable.simulate('press');

expect(onCloseSpy).toHaveBeenCalledWith();
expect(onCloseSpy).toHaveBeenCalledWith(true);
});

it('should close the modal when the empty area above the picker is tapped', () => {
Expand Down