air-datepicker
air-datepicker copied to clipboard
[BUG] Option `selectedDates` doesnt work for all date in the same month (from the maxDate) earlier than year of maxDate (when `maxDate` is today)
I've using selectedDates to select a date on month June 2022. Today (the day this issue created) is 19 June 2023
const plainDate= '07 Jun 2022'
new AirDatepicker('#myInput', {
maxDate: new Date(),
locale: localeEn,
dateFormat: "dd MMM yyyy",
position: "top right",
selectedDates: [DateTime.fromISO(new Date(plainDate).toISOString()).toFormat('yyyy-LL-dd')]
});
It's not selected (const plainDate= '07 Jun 2022'
)
This is also not selected (const plainDate= '07 Jun 2021'
)
But when i change it to const plainDate= '07 Jun 2023'
(which is current year before maxDate) it's work
Or const plainDate= '07 Jul 2022'
(1 year earlier than maxDate) also work
Or const plainDate= '07 May 2022'
(1 year earlier than maxDate) also work
I dont know the "main bug" of this. I cant test all the date exist in this world
@BariqDharmawan actually it is selected, just not visible. You should set view date manually by providing it to startDate
or by using method setViewDate
(https://air-datepicker.com/ru/methods?scrollTo=setViewDate)
But why when the value is current month current year (07 Jun 2023) in my example, when this issue created, it's selected and visible, without using setViewDate
? Perhaps i could contribute to fix this
It's because calendar is already displays current date and there is no need to change the view date.
I'm also having issues with "selectedDates" not working. Totally stuck! Using v2.2.3 and example code below. All works apart from "selectedDates", Its completely ignored. I need multiple dates to be selected as part of the page loading.
<input type="text" id="Calendar1" name="Calendar1" data-inline="true" data-language="en" data-date-format="yyyy-mm-dd" class="" />
<script> $('#Calendar1').datepicker({ startDate: '2023-09-01', multipleDates: true, selectedDates: ['2023-09-05', '2023-09-22'], firstDay: 1, clearButton: true, }); </script>
Any ideas? Appreciate the help, thanks.
Seems v2.2.3 does not support "selectedDates". v3.4.0 works OK, but I have another issue where it keeps showing the latest date, for example, I have 8 dates selected for Nov 2023 and 1 date in Dec 2023. My "startDate" for the calendar is "2023-11-5" which should show the Nov 2023 calendar... but it doesn't, it shows Dec 2023. This is incorrect. Any fix?