Skip to content

Commit

Permalink
Merge pull request mskocik#160 from whishkid/bug/159-right-calendar-n…
Browse files Browse the repository at this point in the history
…ext-month-when-selection-onemonth

Fill right calendar with next month if the date selection is within o…
  • Loading branch information
mskocik authored Feb 20, 2024
2 parents fb0dadd + 48456ac commit 61fe503
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lib/components/Calendar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@
let internalDate = dates[wid] || null;
let activeDate = wid === 1
? (() => {
if (dates.length === 2 && dates[1]) return dates[1];
//if the end date is set, and the month/year is different from the start month/year
// then return that, otherwise return the month succeeding the start date
if (dates.length === 2 && dates[1] && (dates[0].getMonth() != dates[1].getMonth() || dates[0].getFullYear() != dates[1].getFullYear())) return dates[1];
const d = new Date(dates[0] || new Date());
d.setMonth(d.getMonth()+1); // by default move second calendar by 1 month
return d;
Expand Down

0 comments on commit 61fe503

Please sign in to comment.