Skip to content

fix(Calendar): Shift+Page Up and Shift+Page Down move by a year - #9609

Merged
nynexman4464 merged 6 commits into
mainfrom
nynexman4464/fix/calendar-year-paging
Nov 3, 2026
Merged

nynexman4464 merged 6 commits into
mainfrom
nynexman4464/fix/calendar-year-paging

Conversation

@nynexman4464

@nynexman4464 nynexman4464 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

User impact

Keyboard users of Calendar, and of the date fields whose desktop picker is a Calendar, press Shift+Page Up or Shift+Page Down to move by a year. Instead, the focused day moves by one month, the same as Page Up and Page Down. Reaching a date a few years away, such as a birth date or an expiry date, takes twelve presses per year.

Problem and solution fit

  • Why it occurs: the grid's key handler maps Page Up and Page Down to the month step without checking Shift.
  • Why it harms the task: the key a keyboard user expects for a year does a month, so long jumps take many presses.
  • Why it matters: the APG date picker gives Shift+Page Up and Shift+Page Down to the year, so users who know that pattern get a different result.

The month grid now handles Shift+Page Up and Shift+Page Down first and asks for a year step. The year step runs through the same navigation code as the month step.

Expected behavior and authority

  • WAI-ARIA APG Date Picker Dialog: "Shift + Page Up: changes the grid of dates to the same date in the previous year", and Shift + Page Down to the next year.
  • component:DateInput AR8 already names Shift+Page Up and Shift+Page Down moving by a year, for the touch calendar.
  • component:Calendar AR1 names Page Up and Page Down moving by a month. spec:AST-020 FR15 requires the owning record to name any key added beyond the grid pattern, so this PR adds the Shift+Page year step to AR1 as a named exception. The record change needs the Calendar owner's approval.

Fixes #8947.

Smallest restoration

  • The year step uses the same rules as the month step:
    • a day that does not exist (February 29) clamps to the month's last day;
    • a target past min or max changes nothing and keeps focus;
    • a target that a constraint disables focuses that month's first enabled day;
    • in a two-month view, Shift+Page Down shows the target month second and Shift+Page Up shows it first, as Page Down and Page Up do.
  • useGridFocus passes the key event to onPageUp and onPageDown, so Calendar reads Shift from it and there is one page-key path. This is additive: existing callbacks that take no argument still work and still type-check.
  • Plain Page Up and Page Down still move by a month.

Evidence

  • Reproduction before the change (Chromium, Storybook): Shift+Page Down from 2026-03-15 focuses 2026-04-15, and from 2024-02-29 it focuses 2024-03-29.
  • Result after the change: 2026-03-15 → 2027-03-15 and 2024-02-29 → 2025-02-28. Shift+Page Up returns to 2026-03-15 and 2024-02-28.
  • Representative unchanged path: plain Page Down still moves one month (2026-03-15 → 2026-04-15).
  • Regression proof: five new Calendar.test.tsx cases (year step, February 29, past max, constraint fallback, two-month view) and one useGridFocus.test.tsx case (the page callbacks receive the key event). All six fail with the source change reverted.

Writing rubric results

  • R1 narration: none. The AR1 addition states the key behavior in the present tense.
  • R2 research in the record: none.
  • R3 evidence naming a change: none. The verification map names the five new Calendar test cases.
  • R4 rejected alternatives: none.
  • R5 pull request or issue references: none added.
  • R6 ruled open questions: none touched.

Screenshots

Real Chromium against Storybook. Focus starts on the day shown, then Shift+Page Down.

Before After
2026-03-15 before: April 2026 after: March 2027
2024-02-29 before: March 29 2024 after: February 28 2025

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label. The one additive API change, useGridFocus passing the key event, is called out above.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm exec vitest run --project ui packages/core/src/Calendar packages/core/src/hooks/useGridFocus.test.tsx: 240 passed.
  • pnpm check:knowledge: passes.
  • Real Chromium (Playwright) against Storybook: keyboard Shift+Page Down and Shift+Page Up from 2026-03-15 and 2024-02-29. After each key, the focused data-date and the grid name were read.

@vercel

vercel Bot commented Nov 2, 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 Nov 3, 2026 8:40pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 2, 2026
@astracat-bot

astracat-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 3, 2026, 8:53 PM UTC

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 575f02e

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
Calendar · Storybook 54.7 kB (+32 B) · 10.4 kB CSS (0) 1,655 (+9) ✓ · ✓ · ✓
DateRangeInput 72.1 kB (+32 B) · 11.9 kB CSS (0) — — · — · —
DateInput 106.0 kB (+27 B) · 15.4 kB CSS (0) — — · — · —
9 more components
Component Size LoC Visual · A11y · RTL
DateTimeInput 162.6 kB (+26 B) · 17.1 kB CSS (0) — — · — · —
PowerSearch 194.3 kB (+19 B) · 21.6 kB CSS (0) — — · — · —
lab/ChatEmojiPicker 66.9 kB (new) · 773 B CSS (new) — — · — · —
lab/ChatReactionBar 67.4 kB (new) · 1.1 kB CSS (new) — — · — · —
lab/CommentComposer 105.5 kB (new) · 1.9 kB CSS (new) — — · — · —
lab/Comments 259.2 kB (new) · 2.5 kB CSS (new) — — · — · —
lab/CommentThread 254.1 kB (new) · 2.4 kB CSS (new) — — · — · —
lab/EmojiPicker 71.2 kB (new) · 722 B CSS (new) — — · — · —
lab/MobilePowerSearch 218.8 kB (new) · 1.2 kB CSS (new) — — · — · —

Package size: measured; main has no measurement of the merge base to compare yet.

API changes: core +0 · ~2 · −0

Committed API report behind this build: core 2 rows; run pnpm api:report.

2 API changes (advisory)
Package Where Signature Usage
~ core . · Types · interface UseGridFocusOptions onPageDown?: () => void → onPageDown?: (event: React.KeyboardEvent) => void import type {UseGridFocusOptions} from '@astryxdesign/core'; const x: UseGridFocusOptions = {onPageDown: …}
~ core . · Types · interface UseGridFocusOptions onPageUp?: () => void → onPageUp?: (event: React.KeyboardEvent) => void import type {UseGridFocusOptions} from '@astryxdesign/core'; const x: UseGridFocusOptions = {onPageUp: …}

Touched components checked; add ci:run-visual, ci:run-a11y or ci:run-rtl to run the full suites.

Current run: CI concluded cancelled; parts of this report may be missing.


Generated by PR Enrichment workflow | View full report

@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.

The Shift+Page Up and Shift+Page Down year step works as described: the five new tests fail without the change and pass with it, and plain Page Up and Page Down still move a month. Approval waits on one spec decision, because the change intentionally amends the Calendar accessibility contract (AR1), which today names only Page Up and Page Down moving by a month: an engineering owner needs to approve or reject the Shift+Page year step as a named exception, including the February 29 to February 28 clamp. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner. Two optional source-comment tidy-ups are noted inline.

[Automated review]

Comment thread packages/core/src/Calendar/Calendar.tsx Outdated
Comment on lines +522 to +526
// A page targets the same day of the month a month or a year away,
// clamped to that month's length. Past `min`/`max` nothing moves; a
// month with no enabled day is no destination either, the same as an
// arrow with no enabled day in its direction; a target disabled by a
// constraint lands on that month's first enabled day instead.

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.

Optional: the second sentence runs 42 words over three topics and restates the inRange and firstEnabledDayOfMonth lines below. A shorter version that keeps only the reason:

// A page or a year step keeps the day of the month and clamps it to the
// target month's length. A month with no enabled day is no target, the same
// as for an arrow.

Comment thread packages/core/src/Calendar/Calendar.tsx Outdated
);

// Handle PageUp/PageDown
// PageUp/PageDown move by a month. useGridFocus calls these without the

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.

Optional: "PageUp/PageDown move by a month." restates the 'months' argument below; the next sentence, the useGridFocus constraint, is the part worth keeping.

@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.

The Shift+Page Up and Shift+Page Down year step works as described: the five new tests fail without the change and pass with it, in the browser Shift+Page Down moves January 15, 2026 to January 15, 2027, and plain Page Up and Page Down still move a month. Approval waits on one spec decision, because the change intentionally amends the Calendar accessibility contract (AR1), which today names only Page Up and Page Down moving by a month: an engineering owner needs to approve or reject the Shift+Page year step as a named exception, including the February 29 to February 28 clamp. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner. Nothing else needs to change; as a small note, the description's two-month line holds only for Shift+Page Down, since Shift+Page Up makes the target month the first one shown.

[Automated review]

@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.

The Shift+Page Up and Shift+Page Down year step works as described: the six new tests fail without the change and pass with it, and in the browser Shift+Page Down moves January 15, 2026 to January 15, 2027 while plain Page Down still moves a month. Approval waits on two owner decisions: the change intentionally amends the Calendar accessibility contract (AR1), which today names only Page Up and Page Down moving by a month, so an engineering owner needs to approve or reject the Shift+Page year step as a named exception, including the February 29 to February 28 clamp, by commenting /approve-spec <full head SHA> on this pull request (the author may do so as an engineering owner); and an owner needs to accept, split or remove the new event parameter on the public useGridFocus onPageUp and onPageDown options, which no current spec covers. Separately, the description's claim that a two-month view shows the target month last holds only for Shift+Page Down, since Shift+Page Up shows it first.

[Automated review]

Comment on lines +965 to +966
// PageUp/PageDown move by a month, and with Shift by a year (APG date
// picker dialog).

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.

Optional: this restates the e.shiftKey ? 'years' : 'months' argument below. Keeping only the reason:

// The APG date picker dialog gives Shift+Page to the year.


[fix] Calendar: Shift+Page Up and Shift+Page Down now move the focused day to the same date one year earlier or later, as in the WAI-ARIA date picker pattern, instead of one month. A February 29 lands on February 28 in a year without one. The year step follows the same rules as Page Up and Page Down: it changes nothing past `min` or `max`, and on a day that `dateConstraints` disables it focuses that month's first enabled day.

`useGridFocus` now passes the key event to `onPageUp` and `onPageDown`, so a grid can read `event.shiftKey`; callbacks that take no argument keep working.

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.

Optional: if the useGridFocus event parameter stays, it is a compatible capability rather than a fix, so this sentence fits a separate [feat] changeset.

@nynexman4464
nynexman4464 marked this pull request as ready for review November 2, 2026 22:28
@nynexman4464

Copy link
Copy Markdown
Contributor Author

/approve-spec 627d80e

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 3, 2026

@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.

Ready to merge. Shift+Page Up and Shift+Page Down now move Calendar's focused day by a year, the component:Calendar AR1 exception carries an engineering owner's approval for this head, and the useGridFocus event argument was accepted with it. The six new tests fail without the source change and pass with it, and plain Page Up and Page Down still move a month.

Two optional follow-ups, neither blocking:

  • The comment above handlePageUp in Calendar.tsx restates the e.shiftKey ? 'years' : 'months' argument; keeping only the reason (the APG date picker dialog gives Shift+Page to the year) is enough.
  • The useGridFocus event argument is a compatible capability, so it fits a separate [feat] changeset.

[Automated review]

@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.

Ready to merge. Shift+Page Up and Shift+Page Down now move Calendar's focused day by a year, the component:Calendar AR1 exception carries an engineering owner's approval at this head, and the useGridFocus event argument was accepted with it. The six new tests fail without the source change and pass with it, and plain Page Up and Page Down still move a month.

Two optional follow-ups, neither blocking:

  • The comment above handlePageUp in Calendar.tsx restates the e.shiftKey ? 'years' : 'months' argument; keeping only the reason (the APG date picker dialog gives Shift+Page to the year) is enough.
  • The useGridFocus event argument is a compatible capability, so it fits a separate [feat] changeset.

[Automated review]

…ndar-year-paging

# Conflicts:
#	docs/specs/components/Calendar/Calendar.spec.md
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 3, 2026
@nynexman4464

Copy link
Copy Markdown
Contributor Author

/approve-spec 3453864

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 3, 2026

@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.

Recommend approval. Shift+Page Up and Shift+Page Down now move Calendar's focused day by a year, with February 29 clamping to February 28 and the month step's min, max, constraint and two-month rules carried over. The six new tests fail without the change and pass with it, and plain Page Up and Page Down still move a month. The component:Calendar AR1 exception has an engineering owner's approval at this head, and the useGridFocus page-callback change was accepted as additive.

  • Optional: the comment above handlePageUp (Calendar.tsx:968-969) restates the e.shiftKey ? 'years' : 'months' argument; keeping only the reason would read better.

[Automated review]

Comment on lines +968 to +969
// PageUp/PageDown move by a month, and with Shift by a year (APG date
// picker dialog).

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.

Optional (non-blocking): this comment restates the e.shiftKey ? 'years' : 'months' argument below. Keeping only the reason reads better, for example:

// The APG date picker dialog gives Shift+Page a year.

@nynexman4464
nynexman4464 merged commit 85afaa0 into main Nov 3, 2026
91 of 97 checks passed
@github-actions
github-actions Bot deleted the nynexman4464/fix/calendar-year-paging branch November 4, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — 3453864f Deployed Nov 3, 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Calendar: Shift+Page Up and Shift+Page Down move a month instead of a year

1 participant