DateTimePicker: fix when time is disabled click confirm select.

pull/22058/head
王叨叨 2022-08-02 15:48:59 +08:00
parent a99d0cb6fa
commit 7f67ad6df0
1 changed files with 13 additions and 15 deletions

View File

@ -307,14 +307,13 @@
handleTimePick(value, visible, first) {
if (isDate(value)) {
let newDate = '';
if ((!this.disabledDate || !this.disabledDate(new Date())) && this.checkDateWithinRange(new Date())) {
newDate = this.value
? modifyTime(this.value, value.getHours(), value.getMinutes(), value.getSeconds())
: modifyWithTimeString(this.getDefaultValue(), this.defaultTime);
this.date = newDate;
const newDate = this.value
? modifyTime(this.value, value.getHours(), value.getMinutes(), value.getSeconds())
: modifyWithTimeString(this.getDefaultValue(), this.defaultTime);
this.date = newDate;
if (!this.disabledDate || !this.disabledDate(newDate)) {
this.emit(this.date, true);
}
this.emit(newDate, true);
} else {
this.emit(value, true);
}
@ -379,19 +378,18 @@
},
confirm() {
let value = '';
if (this.selectionMode === 'dates') {
this.emit(this.value);
} else {
// 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
if ((!this.disabledDate || !this.disabledDate(new Date())) && this.checkDateWithinRange(new Date())) {
value = this.value
? this.value
: modifyWithTimeString(this.getDefaultValue(), this.defaultTime);
this.date = new Date(value); // refresh date
};
this.emit(value);
const value = this.value
? this.value
: modifyWithTimeString(this.getDefaultValue(), this.defaultTime);
this.date = new Date(value); // refresh date
if (!this.disabledDate || !this.disabledDate(value)) {
this.emit(value);
}
}
},