xgfe / react-native-datepicker

react native datePicker component for both Android and IOS, useing DatePikcerAndroid, TimePickerAndroid and DatePickerIOS
MIT License
2.12k stars 726 forks source link

When mask clicked (onPressMask) saves the date value #327

Open rdewolff opened 5 years ago

rdewolff commented 5 years ago

How can we validate the input when the mask is clicked?

I noticed many user wanting to validate the input by simply clicking on the mask and not on the OK button.

What do you think? How can we achieve that?

izhan commented 5 years ago

+1 to submitting on mask press (I think that's what you mean?)

My workaround for now is using the (undocumented) onPressConfirm:

class MyDatePicker {
  _onPress() {
    const {onPressMask} = this.props;
    this._datePickerRef.onPressConfirm();
    if (onPressMask) {
      onPressMask();
    }
  }

  _onDatePickerRef(ref) {
    this._datePickerRef = ref;
  }

  render() {
    <DatePicker {...this.props} ref={this._onDatePickerRef} onPress={this._onPress} />
  }
}
drop-george commented 5 years ago

@izhan @rdewolff - this PR adds support for exactly this! https://github.com/xgfe/react-native-datepicker/pull/363