Skip to content

CalendarYearPicker omits the final year when both minValue and maxValue are set #10531

Description

@mayagbarnes

Provide a general summary of the issue here

#10140 fixed the maxValue-only case, but the minValue + maxValue path still drops the final year. Year options are built by stepping whole years from minValue, so they carry minValue's month/day and overshoot maxValue whenever maxValue's month/day falls earlier in the year.

🤔 Expected Behavior?

With minValue={2024-08-03} and maxValue={2025-02-03}, the year options should be [2024, 2025] — 2025-01-01 through 2025-02-03 are selectable dates.

😯 Current Behavior

Options are [2024]. The calendar grid shows February 2025 while the year picker trigger reads 2024, because value is an index into items that falls back to 0 when the focused year isn't present.

🔦 Context

In useCalendarYearPicker.ts, the minValue branch resets minDate to minValue and then iterates date.add({years: 1}). Starting from 2024-08-03, the next step is 2025-08-03, which is past maxValue, so 2025 is never pushed.

The condition is (maxValue.month, maxValue.day) < (minValue.month, minValue.day) across different years, which affects roughly half of all year-crossing ranges. Ranges whose bounds share a month/day (e.g. 2024-08-03 → 2025-08-03) are unaffected.

🖥️ Steps to Reproduce

<Calendar
  minValue={new CalendarDate(2024, 8, 3)}
  maxValue={new CalendarDate(2025, 2, 3)}
  focusedValue={new CalendarDate(2025, 2, 1)}
>
  <CalendarMonthPicker>{p => <Select {...p} />}</CalendarMonthPicker>
  {/* options: ["2024"] — 2025 missing, trigger shows 2024 */}
  <CalendarYearPicker>{p => <Select {...p} />}</CalendarYearPicker>
</Calendar>

The month picker is unaffected and correctly shows February.

Version

react-aria-components 1.20.0 / react-aria 3.51.0

What browsers are you seeing the problem on?

Firefox, Chrome, Safari, Microsoft Edge

What operating system are you using?

macOS

🕷 Tracking Issue

Related: #10140 (fixed the maxValue-only case)

Downstream report: streamlit/streamlit#16686

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions