Skip to content

Commit dfc0b4d

Browse files
committed
fix(VueDatePicker): menu not opening when centered prop is enabled
When the centered prop is enabled, the datepicker menu does not open after clicking the input. The issue was caused by the shouldRender ref being initialized as false for non-inline modes, preventing the menu from rendering even when isOpen was true. Modified shouldRender initialization to include rootProps.centered condition. Now shouldRender is true when either inline.enabled or rootProps.centered is active. The existing watcher logic remains unchanged and only affects floating (non-centered, non-inline) mode. Added test case to verify menu opens correctly in centered mode. Changes: - VueDatePicker.vue - TestSuite_1.spec.ts Fixes #1195
1 parent 193e117 commit dfc0b4d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/VueDatePicker/VueDatePicker.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
118118
const slots = useSlots();
119119
const isOpen = ref(false);
120-
const shouldRender = ref(inline.value.enabled);
120+
const shouldRender = ref(inline.value.enabled || rootProps.centered);
121121
const modelValueRef = toRef(rootProps, 'modelValue');
122122
const timezoneRef = toRef(rootProps, 'timezone');
123123

src/VueDatePicker/__tests__/TestSuite_1.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,11 @@ describe('Test Suite 1', () => {
6060
expect(getMonthToggleBtn(dp).text()).toEqual(getMonthToggleText(nextMonth));
6161
});
6262
});
63+
64+
describe('centered option', () => {
65+
it('Should open menu when centered is enabled', async () => {
66+
const dp = await openMenu({ centered: true });
67+
expect(dp.find('.dp__menu').exists()).toBe(true);
68+
});
69+
});
6370
});

0 commit comments

Comments
 (0)