Open
Description
Describe the bug
When both startDate
and defaultYear
/ defaultMonth
are defined, then defaultYear
/ defaultMonth
is ignored.
I understand that this might be expected behaviour, but currently, there is no way to specify a startDate
and also set the defaultMonth
/ defaultYear
to a different value.
To Reproduce
Steps to reproduce the behavior:
- Set up a date picker with below code:
<!-- src/routes/book-appointment/[[date]]+page.svelte -->
<script lang="ts">
import { page } from '$app/stores';
let selectedDate = $page.params.date ? new Date($page.params.date) : undefined;
let defaultDate = $page.url.searchParams.has('viewFrom') ? new Date($page.params.get('viewFrom')) : undefined;
</script>
<DatePicker
bind:startDate={selectedDate}
showYearControls={false}
defaultYear={defaultDate?.getFullYear()}
defaultMonth={defaultDate?.getMonth()}
isOpen={true}
alwaysShow={true}
enableFutureDates={true}
enablePastDates={false}
/>
Expected behavior
I expect the calendar to show the month of June, and if I navigate back to June, then the 15th of March will be selected.
Actual behavior
The calendar shows the month of March, with the 15th of March selected.