Skip to content

Commit

Permalink
fix: calendars not rendering first day of next month
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte committed Oct 17, 2024
1 parent 07bfcd4 commit a23230b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/green-pumpkins-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"bits-ui": patch
---

fix: bug with calendar months sometimes not rendering the first day of the month
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,13 @@ function createMonth(props: CreateMonthProps): Month<DateValue> {
startFrom = dateObj.add({ months: 1 }).set({ day: 1 });
}

const extraDaysArray = Array.from({ length: extraDays }, (_, i) => {
let length = extraDays;
if (nextMonthDays.length === 0) {
length = extraDays - 1;
nextMonthDays.push(startFrom);
}

const extraDaysArray = Array.from({ length }, (_, i) => {
const incr = i + 1;
return startFrom.add({ days: incr });
});
Expand Down

0 comments on commit a23230b

Please sign in to comment.