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 @@