Vuepic / vue-datepicker

Datepicker component for Vue 3
https://vue3datepicker.com
MIT License
1.4k stars 137 forks source link

Changing DatePicker mode when menu open does not work #860

Closed Fleximex closed 2 months ago

Fleximex commented 2 months ago

Describe the bug When trying to change the mode of the DatePicker while it is opened the behaviour of the DatePicker breaks.

I'm trying to add an 'exclude' mode to my DatePicker. Normally it works in 'range' mode. I want the DatePicker to be able to switch to 'multi-dates' mode while the DatePicker is open. This way I could simulate a sort of exclude mode.

When switching the mode from 'range' to 'multi-dates' the selected date range will switch to the first and last date of the range. Logically, something I can fix. However when selecting a date it will now select an 'invalid date' and show today being selected in the picker.

When switching the mode from 'multi-dates' to 'range' you can't select a date.

When switching modes, but in between closing and opening the DatePicker, the behaviour is normal.

To Reproduce const isRangeMode = ref(false) :range="isRangeMode" :multi-dates="!isRangeMode"

Basic example https://stackblitz.com/edit/vuepic-vue-datepicker-e4zhgw?file=src%2Fcomponents%2FPlayground.vue

Expected behavior Being able to select dates or a range after switching modes, while keeping the menu open.

Tested on vue-datepicker v8.5.1

@Jasenkoo Besides my solution (switching DatePicker modes on the fly), maybe you have a different idea for me on how to implement an 'exclude days from selection' mode, when already having a range of dates selected. This is what I'm trying to achieve: Exclude mode, a single date excluded