Merge pull request #2590 from Ancient-Dragon/bugfix/#2588
Fix calendar selecting time when in range modepull/2593/head
commit
0a0c77b426
|
@ -23,7 +23,7 @@ describe('Calendar.vue', () => {
|
|||
expect(wrapper.find('.p-inputtext').exists()).toBe(true);
|
||||
|
||||
let input = wrapper.find('.p-inputtext');
|
||||
|
||||
|
||||
await input.trigger('focus');
|
||||
|
||||
expect(wrapper.find('.p-datepicker.p-component').exists()).toBe(true);
|
||||
|
@ -42,4 +42,12 @@ describe('Calendar.vue', () => {
|
|||
await wrapper.vm.onDateSelect({currentTarget: {focus: () => {}}}, event);
|
||||
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() {
|
||||
let propValue = this.modelValue;
|
||||
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') {
|
||||
return propValue;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
let today = new Date();
|
||||
if (this.maxDate && this.maxDate < today) {
|
||||
return this.maxDate;
|
||||
|
|
Loading…
Reference in New Issue