Merge pull request #6415 from avramz/fix/datepicker-manual-input-year
#6347 fix: Datepicker -> Allow user to set year via input when view="year"pull/6471/head
commit
30c4d0ae66
|
@ -98,4 +98,24 @@ describe('DatePicker.vue', () => {
|
||||||
|
|
||||||
expect(wrapper.find('.p-datepicker-other-month span').exists()).toBe(true);
|
expect(wrapper.find('.p-datepicker-other-month span').exists()).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should correctly set the year when view="year" and value is set via the input', async () => {
|
||||||
|
const dateOne = new Date();
|
||||||
|
const dateTwo = new Date();
|
||||||
|
|
||||||
|
dateTwo.setFullYear(1988, 5, 15);
|
||||||
|
|
||||||
|
await wrapper.setProps({ view: 'year', dateFormat: 'yy', modelValue: dateOne });
|
||||||
|
|
||||||
|
const input = wrapper.find('.p-datepicker-input');
|
||||||
|
|
||||||
|
await input.trigger('focus');
|
||||||
|
|
||||||
|
expect(wrapper.find('.p-datepicker-decade').exists()).toBe(true);
|
||||||
|
expect(wrapper.find('.p-datepicker-decade').text()).toBe('2020 - 2029');
|
||||||
|
|
||||||
|
await wrapper.setProps({ modelValue: dateTwo });
|
||||||
|
|
||||||
|
expect(wrapper.find('.p-datepicker-decade').text()).toBe('1980 - 1989');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1911,6 +1911,11 @@ export default {
|
||||||
day = 1;
|
day = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.currentView === 'year') {
|
||||||
|
day = 1;
|
||||||
|
month = 1;
|
||||||
|
}
|
||||||
|
|
||||||
for (iFormat = 0; iFormat < format.length; iFormat++) {
|
for (iFormat = 0; iFormat < format.length; iFormat++) {
|
||||||
if (literal) {
|
if (literal) {
|
||||||
if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
|
if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
|
||||||
|
|
Loading…
Reference in New Issue