Skip to content

feat(core): add Calendar month/year caption pickers - #4979

Closed
AKnassa wants to merge 4 commits into
meta:mainfrom
AKnassa:rocky/issue-4941-calendar-caption-nav
Closed

AKnassa wants to merge 4 commits into
meta:mainfrom
AKnassa:rocky/issue-4941-calendar-caption-nav

Conversation

@AKnassa

@AKnassa AKnassa commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

What this does

Adds an optional month and year picker to the calendar header. Turn on hasMonthYearPickers and the caption becomes two small dropdowns, so you can jump straight to June 1990 instead of clicking the arrow button dozens of times.

Why

Picking a distant date (a birth date, an old record) takes one click per month today. That is slow for everyone and much worse for keyboard and screen reader users. This pattern is standard in every major date picker library.

Closes #4941

What changed

  • New hasMonthYearPickers option on Calendar, off by default. Nothing changes unless you turn it on.
  • The year list follows the calendar's existing min and max limits (1900 to 2099 when unlimited). Months and years outside the limits are disabled rather than hidden.
  • Jumps announce the new month to screen readers, the same way the arrow buttons do.
  • Themes can style the new dropdowns through a new calendar-picker target.
  • With two months side by side, the caption stays as it was, since it names both months.
  • English docs, Chinese docs, dense docs, two Storybook stories, and a changeset are included.

How to see it

Run Storybook (pnpm dev) and open Core/Calendar, stories "Month Year Pickers" and "Month Year Pickers With Min Max".

Notes for maintainers

  • This is an implementation offer for the RFC while it awaits a design brief. The API deliberately avoids captionLayout, fromYear, and toYear: the year range reuses the existing min/max props instead of adding a second bounds vocabulary, per the API conventions. Glad to rework the shape if arbitration lands somewhere else.
  • RounakKumarAgarwal asked in the issue thread to take this on. If assigning it to them is preferred, treat this branch as a reference and I am happy to close.
  • Two small quirks are inherited from Selector and left unchanged here, both noted in the commit message: type-ahead on the closed trigger announces twice, and opening with an arrow key can highlight a disabled option.
  • Tests were written first (20 new), plus mutation testing (7 of 7 mutants caught). Full suite is green apart from the two known macOS-only CLI failures.

Calendar's caption was a static label, so reaching a distant month —
a birth date, a years-old record — meant paging prev/next one month
at a time, or falling back to error-prone typed input. Screen-reader
and keyboard users bore the worst of it: "press next 200 times" is
not a strategy.

New hasMonthYearPickers prop (default off) replaces the caption with
compact Month and Year pickers built from the existing ghost Selector
— the same compact-embedding pattern Pagination uses, and the same
popover machinery PowerSearch already nests, so a Calendar inside a
DateInput popover stays layering-safe by construction.

API shape follows house convergence rules rather than the RFC's
react-day-picker vocabulary: no captionLayout/fromYear/toYear — the
year list derives from the existing min/max bounds (1900–2099 when
unbounded), always widened so the visible year stays labeled, with
out-of-bounds months and years disabled rather than hidden. Jumps
route through the same controlled/uncontrolled branch as prev/next,
clamp into the [min, max] month window, and inherit the existing
month-change screen-reader announcements. A two-month view keeps the
static caption, which labels both visible months. Themeable via the
new calendar-picker target (data-picker="month" | "year") on a
wrapper node, since Selector splits className and data-* props
across two elements.

Tests written red-first (17 new, 3 more from adversarial review);
mutation testing kills 7/7 targeted mutants, including the max-side
clamp a first pass left unpinned. Known Selector-wide limitations,
disclosed not patched here: closed-trigger typeahead double-announces
(Selector speaks the label, Calendar the month), and arrow-opening a
picker can highlight a disabled option where Enter is a silent no-op.

Refs meta#4941
@vercel

vercel Bot commented Aug 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Sep 26, 2026 4:30am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 13, 2026
@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge needs:design-review Affects visuals — Design should review labels Aug 13, 2026
@github-actions

github-actions Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

Modified Components

Calendar (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1619 -
Complexity N/A Very High (163) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.9KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

1 of 422 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
SideNav Resizable in AppShell probe dark 3,208

Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

github-actions Bot added a commit that referenced this pull request Aug 13, 2026
@AKnassa
AKnassa marked this pull request as ready for review August 13, 2026 21:14

@kentonquatman kentonquatman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sandbox preview isn't working right now for the design review. Would you be able to update or add screenshots to show the change?

@AKnassa

AKnassa commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor Author

The hosted previews for this PR 404 now, though build-sandbox and build-storybook both passed on this commit, so I think the Pages artifact was cleaned up rather than failing to build. I captured these from a local Storybook build of the branch at 1ccbb30.

Before and after

01-before-after

Left is the caption today, right is hasMonthYearPickers on the same component, sitting at June 1990.

Month picker
02-month-picker-open

Year picker, no bounds set
03-year-picker-open

Year picker with min="2024-06-10" and max="2027-03-20"
04-minmax-year-list

The list offers 2024 to 2027 only, derived from the existing min/max rather than a second bounds vocabulary.

After picking 2024
05-minmax-months-disabled

The jump clamps to June, the first month inside min. January to May stay visible but disabled, and the prev arrow is disabled at the bound.

Dark mode

06-dark-month-open

I left the two month view out because it is unchanged: the pickers are ignored when numberOfMonths is 2, where the caption already names both visible months.

Happy to capture any other state that would help.

@rubyycheung

Copy link
Copy Markdown
Contributor

@imdreamrunner, now that the mobile date-picker work has landed (#5243 and #5582), could you help us resolve the direction for this PR? Should these month/year caption pickers remain a desktop Calendar option, be shared with the mobile picker, or be superseded by the newer mobile navigation pattern? I would like to avoid landing a second navigation model that conflicts with the mobile experience.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the detailed implementation, tests, and screenshots.

This change is waiting on a maintainer decision before it can be approved. The proposal adds a new public Calendar prop (hasMonthYearPickers), replaces the single-month caption with Month and Year dropdowns, adds bounds, clamping, and announcement behavior, and adds a new calendar-picker theme target — but there is no governing spec yet for that addition. The PR itself describes this as an implementation offer for the RFC while it awaits a design brief, so a maintainer needs to provide or identify the governing spec and settle, in particular:

  • Whether this should remain an opt-in desktop Calendar feature, be redesigned to share the newer mobile date-picker navigation model, or be superseded by it
  • The final prop name and shape, the year-range and min/max behavior, and the two-month exception

One implementation point to fix if that direction is approved: styling set through the calendar-picker theme target (for example its color and fontWeight) currently lands on a wrapper and does not reach the visible picker label, because the inner Selector sets its own text color and font weight. Routing the target to the rendered control and checking the rendered styles would close that.

No changes are being requested solely because the spec is missing — approval is waiting on the maintainer spec decision above.

[Automated review]

No textual conflicts. Calendar.tsx, Calendar.test.tsx, Calendar.doc.mjs
and styles.ts auto-merged cleanly alongside upstream's Calendar work
(meta#5306 min/max opening month, meta#5453 320px reflow, meta#5120/meta#5303 locale,
meta#6121 theme selectors).

Merge fallout fixed here:

- astracat F4: meta#6121 moved generated variant selectors from bare
  classes to data attributes, so the calendar-picker defineTheme
  assertion now expects `.astryx-calendar-picker[data-picker="year"]`
  instead of the stale `.astryx-calendar-picker.year`, matching how
  meta#6121 updated the sibling calendar-nav assertion. Red before: "expected
  ... to contain '.astryx-calendar-picker.year'" (Calendar.test.tsx:1885).

- Provider locale: meta#5120/meta#5303 moved the static caption onto the
  InternationalizationProvider locale and added the
  @astryx/no-raw-intl-locale lint rule, which the picker option labels
  (still undefined-locale) now fail. They pass `locale` like the caption
  again, so the two caption modes keep agreeing on month names. New test
  "labels the month picker in the provider locale, like the static
  caption" was red first (es-ES rendered "March", expected "marzo").

Calendar.test.tsx 112/112 green after both.
astracat F3: the calendar-picker target sits on a wrapper span (Selector
puts className on its trigger container but data-* on the inner button,
and meta#6121's variant rules need class and data-picker on one node), but
the ghost Selector trigger sets its own color and font-weight, so a
theme's color or fontWeight on the target painted the wrapper and never
reached the visible Month/Year label.

The wrapper (pickerItem) now owns the caption's color and weight, using
the ghost Selector's defaults (--color-text-primary, medium) so the
default look is unchanged, and each Selector gets
xstyle={calendarStyles.pickerTrigger} to inherit both. Surface styles
(background, padding, radius) on the target still paint the wrapper.

Proof: new test "lets a color themed on calendar-picker reach the
visible picker label" was red first (expected 'var(--color-text-primary)'
to be 'rgb(255, 0, 0)') and is green now; Calendar suites plus
themingTargets.test.ts 626/626.
The pre-commit hook (lint-staged: eslint --fix + prettier --write) ran
over every file the upstream/main merge staged, so merge commit
2c30e68 also reformatted 14 upstream files this PR does not touch.
This puts them back to upstream/main's exact bytes so the PR diff is
only the 7 Calendar files again.

Committed with --no-verify because upstream's own copies of these files
fail `prettier --check`, so lint-staged would reformat them again. The
hook's other half, `pnpm check:repo`, was run by hand and passes.

Restored: IME_GUARD_DESIGN.md,
apps/storybook/stories/MobileTokenizer.stories.tsx,
internal/vibe-tests/stepper-collapse-naming-test/PLAN.md and
docs/arm-{a-collapsed,b-bare,c-summary,d-enum,recall}.md,
packages/core/src/Carousel/Carousel.test.tsx,
packages/core/src/Chat/__tests__/ChatMessageMetadata.a11y.chromium.spec.ts,
packages/core/src/TextInput/TextInput.test.tsx,
packages/core/src/theme/syntax/index.ts,
packages/lab/src/MobileTokenizer/MobileTokenizer.{tsx,test.tsx}.
@AKnassa

AKnassa commented Sep 26, 2026

Copy link
Copy Markdown
Contributor Author

Pushed an update at e170650, with main merged in.

  • Theme color/fontWeight on calendar-picker not reaching the label: fixed in fd5cc89. The wrapper now owns the caption's color and font weight, using the ghost Selector's defaults so the default look is unchanged, and both Selector triggers inherit them. A new test checks that a themed color reaches the visible Month/Year label. I didn't move the target onto the Selector as suggested: Selector puts className on its container and data-* on the inner button, and since fix(theme): remove bare prop and state classes #6121 the variant rules need the class and data-picker on the same node. Background, padding and radius set on the target still paint the wrapper.
  • Main merge (2c30e68): no conflicts. The theme assertion now expects the [data-picker="year"] form from fix(theme): remove bare prop and state classes #6121, and the picker labels use the provider locale like the static caption (new es-ES test). e170650 reverts formatting my pre-commit hook applied to 14 unrelated upstream files, so the diff is back to the Calendar files only.

Still open:

  • @imdreamrunner, one data point for @rubyycheung's question: on coarse pointers DateInput renders TouchDateField, which already has its own month/year wheels, so these popups only overlap with a standalone Calendar on touch. If you'd prefer Calendar follow the mobile model (tap the title to swap the grid for an inline month/year view, no popup), I'm happy to rework it. The prop name, year range and two-month behavior are unchanged until that's decided.
  • @kentonquatman, the screenshots you asked for are in my Aug 17 comment. Could you take another look when you have a moment?

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the careful implementation, tests and screenshots; the design review has approved the visuals, but approval still waits on a maintainer decision: no current spec covers month and year pickers in Calendar, so an engineering owner needs to provide or identify the governing spec and settle whether this stays an opt-in Calendar option, adopts the touch date field’s month/year wheels, or is superseded by them, including the prop name, the 1900–2099 default, the two-month exception and the calendar-picker target. An engineering owner (the author included, if they are one) records that decision by commenting /approve-spec <full head SHA> on this pull request.

Since the last review the Calendar spec became current on main and Calendar now renders calendar systems, so the branch conflicts and needs a rebase, and whichever way the decision goes these need fixing:

  • Newly live check: the pickers list Gregorian months and years, but the current Calendar spec (FR8) requires the month heading to use the calendar system the grid shows, so on main they would name Gregorian months over a Persian or Hebrew grid; build them on the same calendar month model the touch wheels use.
  • Newly live check: the month and year option lists and the year-change clamp duplicate MonthYearWheels in DateInput, which has already moved to calendar systems without this copy; share one helper between the two.
  • The calendar’s width follows the month name (260px in July to 310px in September, against a fixed 248px), so after one Next press from August a second click in the same spot opens the Year list; keep the grid’s width authoritative or give the Month trigger a stable width.
  • The pickers always show Month before Year, so year-first locales such as hu-HU read március then 2026. where the static caption reads 2026. március (also ja-JP, ko-KR, zh-CN and zh-TW); order them from the locale’s month–year format and test one of those locales.
  • Newly live check: the month label uses the lower-case format form (marzo, and the es-ES test pins it), while the current Calendar spec (FR1) requires the header’s stand-alone month to start with a capital in es, fr, pl and ru.
  • Newly live check: data-picker is a new public data attribute with no spec naming it; record it with the calendar-picker decision or drop the picker visual prop.
  • Newly live check: the title’s core scope names no component, so the Calendar API rows sit outside the pull request’s scope; retitle it feat(Calendar): … or add a ## Scope section with Components: Calendar.

Automated review (maintainer link)

@kentonquatman kentonquatman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Design looks good! Thanks @AKnassa!

@github-actions github-actions Bot removed the needs:design-review Affects visuals — Design should review label Oct 31, 2026
@cixzhang

Copy link
Copy Markdown
Contributor

(Posted by Cindy's agent.) Thank you, @AKnassa, for building this! Month and year menus would help people pick dates years away. Since this was written, Calendar has gained support for non-Gregorian calendar systems, and a fixed 1900–2099 Gregorian year list doesn't fit them. It also adds a new theming target. So we're closing this version; if month and year jump menus go ahead, they'll be rebuilt from a Calendar spec line that covers every calendar system and min/max, with you credited.

@cixzhang cixzhang closed this Nov 12, 2026
@github-actions
github-actions Bot deleted the rocky/issue-4941-calendar-caption-nav branch November 13, 2026 13:55

This branch was successfully deployed

1 active deployment
Preview — e170650c Deployed Sep 26, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC] Calendar: add a month/year picker for fast navigation to distant dates

4 participants