Skip to content

Commit

Permalink
Merge pull request #46 from mars-lan/master
Browse files Browse the repository at this point in the history
Make sure that onHideAfterConfirm is only called when the confirm button is pressed
  • Loading branch information
mmazzarolo authored Jun 4, 2017
2 parents ed50fdd + ce0e04a commit b6e9457
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/CustomDatePickerIOS/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,20 @@ export default class CustomDatePickerIOS extends Component {
}
}

_handleConfirm = () => this.props.onConfirm(this.state.date);
_handleCancel = () => {
this.confirmed = false;
this.props.onCancel();
};

_handleConfirm = () => {
this.confirmed = true;
this.props.onConfirm(this.state.date);
}

_handleOnModalHide = () => {
this.props.onHideAfterConfirm(this.state.date);
if (this.confirmed) {
this.props.onHideAfterConfirm(this.state.date);
}
};

_handleDateChange = date => {
Expand All @@ -69,7 +79,6 @@ export default class CustomDatePickerIOS extends Component {

render() {
const {
onCancel,
isVisible,
mode,
titleIOS,
Expand Down Expand Up @@ -137,7 +146,7 @@ export default class CustomDatePickerIOS extends Component {
</View>

<View style={styles.cancelButton}>
<TouchableOpacity onPress={onCancel}>
<TouchableOpacity onPress={this._handleCancel}>
{customCancelButtonIOS || cancelButton}
</TouchableOpacity>
</View>
Expand Down

0 comments on commit b6e9457

Please sign in to comment.