gpbl / react-day-picker

DayPicker is a customizable date picker component for React. Add date pickers, calendars, and date inputs to your web applications.
https://daypicker.dev
MIT License
6.09k stars 732 forks source link

bug: `fixedWeeks` should display 6 weeks if month has 4 weeks #2585

Closed oleynikovoleg closed 2 days ago

oleynikovoleg commented 4 days ago

Code

<DayPicker
  mode="single"
  selected={selectedDate}
  onSelect={handleDataChange}
  hidden={[
    { before: fromDate },
    { after: toDate }
  ]}
  month={selectedMonth}
  onMonthChange={setSelectedMonth}
  showOutsideDays
  fixedWeeks
/>

Expected Behavior

The calendar should consistently display 6 weeks per month when using the fixedWeeks prop, regardless of the month. This should ensure a uniform calendar layout, even for months with fewer than 6 weeks of visible days.

Actual Behavior

In some months, the fixedWeeks prop does not work as expected and displays only 5 weeks instead of 6. This occurs inconsistently, even when fixedWeeks is enabled. The issue is reproducible on the example page as well.

Screenshots

Screenshot 2024-11-14 at 12 30 07 PM Screenshot 2024-11-14 at 12 24 34 PM
gpbl commented 4 days ago

@oleynikovoleg interesting, thanks for the report. It looks like it happens only with February 2026 - i.e. when the 28-day month starts on Sunday. Could you confirm?

oleynikovoleg commented 4 days ago

@gpbl Yes, that’s correct. It seems to occur in February 2026, then again in February 2037, and so on, whenever the month begins on a Sunday and has 28 days. Thanks for pointing that out!

bryce-fitzsimons commented 2 days ago

Came here to report this bug, saw it's already been submitted.

image