Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#6203 fix: switching to year view when modelValue is populated #6204

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions packages/primevue/src/datepicker/DatePicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,26 @@ describe('DatePicker.vue', () => {

expect(wrapper.vm.viewDate).toEqual(dateTwo);
});

it('should open a year view when there is selected date (fix: #6203)', async () => {
const dateOne = new Date();

dateOne.setFullYear(1988, 9, 10);

await wrapper.setProps({ modelValue: dateOne });

const input = wrapper.find('.p-datepicker-input');

await input.trigger('focus');

const yearSelectButton = wrapper.find('.p-datepicker .p-datepicker-select-year');

expect(yearSelectButton.exists()).toBe(true);
expect(yearSelectButton.text()).toBe('1988');

await yearSelectButton.trigger('click');

expect(wrapper.find('.p-datepicker-decade').exists()).toBe(true);
expect(wrapper.find('.p-datepicker-decade').text()).toBe('1980 - 1989');
});
});
2 changes: 1 addition & 1 deletion packages/primevue/src/datepicker/DatePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ export default {

return start === year || end === year || (start < year && end > year);
} else {
return value.getFullYear() === year;
return this.modelValue.getFullYear() === year;
}
},
isDateEquals(value, dateMeta) {
Expand Down
Loading