Skip to content

Commit 97db681

Browse files
committed
Added description on customConfirmButtonWhileInteractingIOS
1 parent 5259fd8 commit 97db681

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/CustomDatePickerIOS/index.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,21 @@ export default class CustomDatePickerIOS extends Component {
8484
);
8585
let confirmButton;
8686

87+
// Interested PR: https://github.com/mmazzarolo/react-native-modal-datetime-picker/pull/40
88+
// Issue on React-Native: https://github.com/facebook/react-native/issues/8169
89+
// Up until now when the user interacted with the picker, if he tapped on the confirm button,
90+
// the state was not yet changed and thus the picked value would be old and miss-leading.
91+
// DatePickerIOS does not update on the fly, and before it even manages to dispatch an update,
92+
// our component is unmounted and thus the state is lost.
93+
// We no longer allow our user to tap the confirm button unless the picker is still.
94+
// They can always tap the cancel button anyway.
8795
if (customConfirmButtonIOS) {
88-
// if we have a custom confirm btn
89-
if (
90-
customConfirmButtonWhileInteractingIOS && // if we have a custom confirm btn while we're interacting
91-
this.state.userIsInteractingWithPicker
92-
) {
93-
// and if we're currently interacting
96+
if (customConfirmButtonWhileInteractingIOS && this.state.userIsInteractingWithPicker) {
9497
confirmButton = customConfirmButtonWhileInteractingIOS;
9598
} else {
96-
// otherwise if we're not interacting etc
97-
confirmButton = customConfirmButtonIOS; // just set our confirm button as the custom confirmation button
99+
confirmButton = customConfirmButtonIOS;
98100
}
99101
} else {
100-
// else if we don't even have a custom confirmation button just create a component now
101102
confirmButton = <Text style={styles.confirmText}>{confirmTextIOS}</Text>;
102103
}
103104
const cancelButton = <Text style={styles.cancelText}>{cancelTextIOS}</Text>;

0 commit comments

Comments
 (0)