Merge pull request #2590 from Ancient-Dragon/bugfix/#2588
Fix calendar selecting time when in range modepull/2593/head
commit
0a0c77b426
|
@ -42,4 +42,12 @@ describe('Calendar.vue', () => {
|
||||||
await wrapper.vm.onDateSelect({currentTarget: {focus: () => {}}}, event);
|
await wrapper.vm.onDateSelect({currentTarget: {focus: () => {}}}, event);
|
||||||
expect(onDateSelect).toHaveBeenCalled()
|
expect(onDateSelect).toHaveBeenCalled()
|
||||||
});
|
});
|
||||||
|
it('should calculate the correct view date when in range mode', async () => {
|
||||||
|
const dateOne = new Date();
|
||||||
|
const dateTwo = new Date();
|
||||||
|
dateTwo.setFullYear(dateOne.getFullYear(), dateOne.getMonth(), dateOne.getDate() + 1)
|
||||||
|
await wrapper.setProps({ selectionMode: 'range', showTime: true, modelValue: [dateOne, dateTwo] });
|
||||||
|
|
||||||
|
expect(wrapper.vm.viewDate).toEqual(dateTwo)
|
||||||
|
});
|
||||||
});
|
});
|
|
@ -2288,13 +2288,16 @@ export default {
|
||||||
viewDate() {
|
viewDate() {
|
||||||
let propValue = this.modelValue;
|
let propValue = this.modelValue;
|
||||||
if (propValue && Array.isArray(propValue)) {
|
if (propValue && Array.isArray(propValue)) {
|
||||||
propValue = propValue[0];
|
if (this.isRangeSelection()) {
|
||||||
|
propValue = propValue[1] || propValue[0];
|
||||||
|
} else if (this.isMultipleSelection()) {
|
||||||
|
propValue = propValue[propValue.length - 1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (propValue && typeof propValue !== 'string') {
|
if (propValue && typeof propValue !== 'string') {
|
||||||
return propValue;
|
return propValue;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
let today = new Date();
|
let today = new Date();
|
||||||
if (this.maxDate && this.maxDate < today) {
|
if (this.maxDate && this.maxDate < today) {
|
||||||
return this.maxDate;
|
return this.maxDate;
|
||||||
|
|
Loading…
Reference in New Issue