DateTimePicker: fix when time is disabled click confirm select.

pull/22057/head
王叨叨 2022-08-02 15:19:49 +08:00
parent 8ab1db83c5
commit a99d0cb6fa
1 changed files with 15 additions and 9 deletions

View File

@ -307,11 +307,14 @@
handleTimePick(value, visible, first) { handleTimePick(value, visible, first) {
if (isDate(value)) { if (isDate(value)) {
const newDate = this.value let newDate = '';
? modifyTime(this.value, value.getHours(), value.getMinutes(), value.getSeconds()) if ((!this.disabledDate || !this.disabledDate(new Date())) && this.checkDateWithinRange(new Date())) {
: modifyWithTimeString(this.getDefaultValue(), this.defaultTime); newDate = this.value
this.date = newDate; ? modifyTime(this.value, value.getHours(), value.getMinutes(), value.getSeconds())
this.emit(this.date, true); : modifyWithTimeString(this.getDefaultValue(), this.defaultTime);
this.date = newDate;
}
this.emit(newDate, true);
} else { } else {
this.emit(value, true); this.emit(value, true);
} }
@ -376,15 +379,18 @@
}, },
confirm() { confirm() {
let value = '';
if (this.selectionMode === 'dates') { if (this.selectionMode === 'dates') {
this.emit(this.value); this.emit(this.value);
} else { } else {
// value were emitted in handle{Date,Time}Pick, nothing to update here // value were emitted in handle{Date,Time}Pick, nothing to update here
// deal with the scenario where: user opens the picker, then confirm without doing anything // deal with the scenario where: user opens the picker, then confirm without doing anything
const value = this.value if ((!this.disabledDate || !this.disabledDate(new Date())) && this.checkDateWithinRange(new Date())) {
? this.value value = this.value
: modifyWithTimeString(this.getDefaultValue(), this.defaultTime); ? this.value
this.date = new Date(value); // refresh date : modifyWithTimeString(this.getDefaultValue(), this.defaultTime);
this.date = new Date(value); // refresh date
};
this.emit(value); this.emit(value);
} }
}, },