Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Option selectedDates doesnt work for all date in the same month (from the maxDate) earlier than year of maxDate (when maxDate is today) #552

Open
BariqDharmawan opened this issue Jun 19, 2023 · 5 comments

Comments

@BariqDharmawan
Copy link
Contributor

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')

image

This is also not selected (const plainDate= '07 Jun 2021')

image

But when i change it to const plainDate= '07 Jun 2023' (which is current year before maxDate) it's work

image

Or const plainDate= '07 Jul 2022' (1 year earlier than maxDate) also work

image

Or const plainDate= '07 May 2022' (1 year earlier than maxDate) also work

image

I dont know the "main bug" of this. I cant test all the date exist in this world

@BariqDharmawan BariqDharmawan changed the title Option selectedDates doesnt work for all date in June before 2023 (current year) when maxDate is today Option selectedDates doesnt work for all date in June before the year of maxDate (when maxDate is today) Jun 19, 2023
@BariqDharmawan BariqDharmawan changed the title Option selectedDates doesnt work for all date in June before the year of maxDate (when maxDate is today) [BUG] Option selectedDates doesnt work for all date in June before the year of maxDate (when maxDate is today) Jun 19, 2023
@BariqDharmawan BariqDharmawan changed the title [BUG] Option selectedDates doesnt work for all date in June before the year of maxDate (when maxDate is today) [BUG] Option selectedDates doesnt work for all date in the same month (from the maxDate) earlier than year of maxDate (when maxDate is today) Jun 19, 2023
@t1m0n
Copy link
Owner

t1m0n commented Jun 22, 2023

@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)

@BariqDharmawan
Copy link
Contributor Author

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

@t1m0n
Copy link
Owner

t1m0n commented Jul 2, 2023

It's because calendar is already displays current date and there is no need to change the view date.

@blandyuk
Copy link

blandyuk commented Jan 17, 2024

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.

@blandyuk
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants