fix(DSTSUP-276): anchor the Calendar year list at year 1 - #5766
Conversation
The year dropdown centres a 41-year window on the focused year, so below year 21 it reached past the Gregorian era boundary. react-aria labels entries with an era only when the focused date is BC, so focused on AD 5 the list read "16 15 … 2 1 1 2 … 25" with two options named "1". Anchor the window at year 1 when the focused year is too low to centre it, keeping 41 entries. Bounded calendars are unchanged.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
🦋 Changeset detectedLatest commit: 7432c0e The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Accessibility tests executed. Download the report here. |
Coverage Report for Marigold Code Coverage
File Coverage
|
||||||||||||||||||||||||||||||||||||||
|
Accessibility tests executed. Download the report here. |
jim761
left a comment
There was a problem hiding this comment.
Automated Code Review
Four notes on the year-window change. The core logic checks out — I traced useCalendarYearPicker in react-aria@3.51.0 and confirmed the window math (focused AD 5 → visibleYears: 73 → 1 … 41 after the filter), and that filtering items is safe for selection because RAC's id is an index into the unfiltered array that onChange resolves by lookup. One warning and three nits below.
Generated with Claude Code review-pr skill
…lendars The year-1 anchor and the era filter both assumed a Gregorian era floor. `focusedDate.year` is era-relative in other calendar systems, so under the Japanese calendar Reiwa 8 clamped to Reiwa 1, and the filter confined the dropdown to the focused era — making pre-2019 unreachable. Both now gate on `calendar.identifier === 'gregory'`, restoring the previous centred, era- crossing window everywhere else. The anchor is also skipped when `minValue` is set, since react-aria already re-anchors the window there. `minValue: AD 1` with a focused AD 5 listed `1 … 73` instead of `1 … 41`. Extracts `YEARS_AROUND_FOCUS` so the 20/40 coupling that keeps the list 41 entries long is explicit, and mirrors the anchor story test in `RangeCalendar`, which already mirrors the min/max clamp test.
|
Accessibility tests executed. Download the report here. |
The anchor was gated on `gregory && !minValue` while the era filter was gated on `gregory` alone, so a BC `minValue` lost the 16 in-range BC years the consumer had explicitly opted into. Both now share one flag. Adds a selection round-trip test pinning that `item.id` indexes react-aria's unfiltered year array, and a Japanese-calendar test pinning that non-Gregorian windows stay centred.
|
Accessibility tests executed. Download the report here. |
Description
Opening the year dropdown on a year below 21 produced a list that counted down and then back up — focused on AD 5 it read
16 15 14 … 2 1 1 2 3 … 25, with two options sharing the accessible name1.CalendarYearPickercentres a fixedvisibleYearswindow on the focused year, so a 41-year window reaches 20 years back. There is no year 0 in the Gregorian calendar, so from AD 5 that lands in 16 BC, and react-aria renders an era marker only when the focused date is BC, never the individual entries. The first 16 options were BC years wearing bare AD numbers.The window is now anchored at year 1 rather than centred whenever the focused year sits too close to the boundary to centre it. The list stays 41 entries long: AD 5 offers
1 … 41, as does AD 1. Since react-aria only shifts its window forminValue, which this component does not own, the window is instead sized to guarantee 41 in-era years and the entries that rolled into the previous era are dropped.minValuecalendars are untouched: react-aria re-anchors its own window there, and a BCminValueis an explicit opt-in, so neither the anchor nor the era filter applies. AmaxValue-only calendar focused below AD 21 does change — the clamp drags the window back across the era boundary and those entries are dropped the same way, somaxValueAD 10 focused on AD 5 lists1 … 10instead of31 BC … AD 10. Every other bounded calendar renders exactly as before: the window still reaches whichever bound is farther and renders every in-range year. Verified against every bound combination (minonly,maxonly, both, wide range, single-year range, BC bounds) before and after the change.Closes DSTSUP-276
Screenshots / Preview
Test Instructions
Components/Calendar/Basicand setdefaultValueto a year below 21, e.g.new CalendarDate(5, 6, 15).1through41ascending — no duplicate1, no descending run at the top.minValueand/ormaxValueset and confirm those lists are unchanged.pnpm test:sb— the newAnchors the year list at year 1 instead of rolling into the previous erastory test covers step 2.Breaking Changes
No
Checklist
component-testtag where applicable)pnpm changeset)