TimePicker: fix verification of time-range

when the time range is changed, only the corresponding time range should be checked
pull/21445/head
冬瓜 2021-11-05 15:58:52 +08:00
parent 5390f4069e
commit 087e4fefd8
1 changed files with 17 additions and 13 deletions

View File

@ -163,20 +163,30 @@
handleMinChange(date) {
this.minDate = clearMilliseconds(date);
if (this.isValidMinValue()) {
this.handleChange();
}
},
handleMaxChange(date) {
this.maxDate = clearMilliseconds(date);
if (this.isValidMaxValue()) {
this.handleChange();
}
},
isValidMinValue() {
return timeWithinRange(this.minDate, this.$refs.minSpinner.selectableRange);
},
isValidMaxValue() {
return timeWithinRange(this.maxDate, this.$refs.maxSpinner.selectableRange);
},
handleChange() {
if (this.isValidValue([this.minDate, this.maxDate])) {
this.$refs.minSpinner.selectableRange = [[minTimeOfDay(this.minDate), this.maxDate]];
this.$refs.maxSpinner.selectableRange = [[this.minDate, maxTimeOfDay(this.maxDate)]];
this.$emit('pick', [this.minDate, this.maxDate], true);
}
},
setMinSelectionRange(start, end) {
@ -217,12 +227,6 @@
}
},
isValidValue(date) {
return Array.isArray(date) &&
timeWithinRange(this.minDate, this.$refs.minSpinner.selectableRange) &&
timeWithinRange(this.maxDate, this.$refs.maxSpinner.selectableRange);
},
handleKeydown(event) {
const keyCode = event.keyCode;
const mapping = { 38: -1, 40: 1, 37: -1, 39: 1 };