From 87c1ba43c14a688b893f73763112e356a98c9f39 Mon Sep 17 00:00:00 2001 From: uros Date: Mon, 2 Sep 2024 14:53:32 +0200 Subject: [PATCH] fix: DatePicker: fix showOtherMonths behaviour so it doesn't show other month's dates (instead of prev/next) fixes #6307 --- .../src/datepicker/DatePicker.spec.js | 22 +++++++++++++++++++ .../primevue/src/datepicker/DatePicker.vue | 17 ++++++-------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/packages/primevue/src/datepicker/DatePicker.spec.js b/packages/primevue/src/datepicker/DatePicker.spec.js index 8543ccb56..3254d07c5 100644 --- a/packages/primevue/src/datepicker/DatePicker.spec.js +++ b/packages/primevue/src/datepicker/DatePicker.spec.js @@ -76,4 +76,26 @@ describe('DatePicker.vue', () => { expect(wrapper.find('.p-datepicker-decade').exists()).toBe(true); expect(wrapper.find('.p-datepicker-decade').text()).toBe('1980 - 1989'); }); + + it('should not show other months when showOtherMonths is false', async () => { + const dateOne = new Date(); + + dateOne.setFullYear(1988, 5, 15); + + await wrapper.setProps({ modelValue: dateOne, showOtherMonths: false }); + + const input = wrapper.find('.p-datepicker-input'); + + await input.trigger('focus'); + + expect(wrapper.find('.p-datepicker-other-month span').exists()).toBe(false); + + await input.trigger('blur'); + + await wrapper.setProps({ showOtherMonths: true }); + + await input.trigger('focus'); + + expect(wrapper.find('.p-datepicker-other-month span').exists()).toBe(true); + }); }); diff --git a/packages/primevue/src/datepicker/DatePicker.vue b/packages/primevue/src/datepicker/DatePicker.vue index 5ed3748ab..740bcb5a7 100755 --- a/packages/primevue/src/datepicker/DatePicker.vue +++ b/packages/primevue/src/datepicker/DatePicker.vue @@ -78,7 +78,7 @@