Vuepic / vue-datepicker

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

Is there a way to programmatically select dates in the picker, without changing the model value? #814

Closed skstuder closed 5 months ago

skstuder commented 5 months ago

I was hoping to use something similar to updateInternalModelValue to update the picker values, but without changing the model value itself.

We have an explicit button for selecting dates. So we need a way to update picker values, show the range, but not actually change the model value until they hit our select button that fires selectDate()

Here is our usecase for reference

We want to let them see what 52 weeks in the past looks like as a selection, without making the selection for them until the click 'select date` button.

Screenshot 2024-04-08 at 9 20 13 AM

Jasenkoo commented 5 months ago

By calling updateInternalModelValue it will just select dates internally in the picker, not the v-model bind.

skstuder commented 5 months ago

@Jasenkoo I just tried to pass a week-picker range into that function and got this error.

Is it setup to handle the [[Date, Date], [Date, Date]] format?

Screenshot 2024-04-08 at 9 08 48 AM

Jasenkoo commented 5 months ago

@skstuder It is not in that format, as the internal model is only Date or Date[], in this case, you pass the starting date from both weeks instead of double array.

skstuder commented 5 months ago

Okay so just: [any date from week 1, any date from week 2]?

Jasenkoo commented 5 months ago

Didn't try it, but it should work. If not, you'll need to use the first date in the week.