Skip to content

fix(Calendar): arrow keys skip borrowed adjacent-month days and cross into their month - #7511

Merged
cixzhang merged 1 commit into
mainfrom
fix/calendar-skip-outside-days-reland
Oct 14, 2026
Merged

cixzhang merged 1 commit into
mainfrom
fix/calendar-skip-outside-days-reland

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

Re-land of #7478, which merged into a stale base (fix/calendar-page-keys, #7467's branch, after GitHub had not yet retargeted it to main). This PR carries exactly #7478's change — its final head e8f17e4's four files on top of main @ 666ad2f (#7467): Changeset +7; Calendar.spec.md +6/−10; Calendar.test.tsx +141/−16; Calendar.tsx +8/−1.

Problem

A keyboard user arrowing through a Calendar could land on a borrowed adjacent-month day — shown dimmed and exposed aria-disabled — and then Enter or Space picked nothing. useGridFocus's isCellFocusable read only native disabled (Calendar.tsx L803–804), and borrowed days are never natively disabled (a click on one navigates). component:Calendar FR5/AR1 (#7464) record this as an implementation gap under the Grid adoption.

Fix

isCellFocusable excludes [aria-disabled="true"] buttons. The hook already continues past non-focusable cells in the same direction and, at the grid edge, calls onNavigateBefore/After, so the month navigates and the pending focus lands on the real day in the month now shown — the behaviour FR5 describes. A borrowed day's click is inert (Calendar.tsx L1167 guards on effectivelyDisabled); pointer focus on one is still possible, which is why the Page-key fix keeps its from-a-borrowed-day clamp.

Stacked on the Page-key fix

Base branch: fix/calendar-page-keys (#7467), whose per-grid pending-focus rule (only the grid showing the target month acts) this fix depends on in a two-month view. New here: an arrow leaving one grid toward a day another grid already shows moves focus there without paging (January 28 → ArrowDown → February 4 in the second grid, view unchanged), while a target outside both grids pages and focuses the real day (February 24 → ArrowDown → March 3). Test: "in a two-month view an arrow from the first month lands on the real day, never a borrowed one" (numberOfMonths={2}).

Evidence

  • Calendar.test.tsx "skips borrowed adjacent-month days and crosses into their month instead": ArrowLeft from January 1, 2026 announces December 2025 and focuses the real December 31 (not aria-disabled). Red arm: fails with Calendar.tsx reverted to main (focus went to the borrowed copy).
  • Two existing cross-month tests ("ArrowDown moves focus +7 days…", "…locale-safe") rendered a controlled Calendar whose onFocusDateChange was a mock, so they passed only by focusing the borrowed February copy; they now use an owner that follows the focus date and assert the real February 4. Both fail on main's Calendar with the new assertions.
  • Calendar + DateInput suites 509/509; tsc, eslint, Prettier clean.

Changeset

@astryxdesign/core patch [fix].

Record

Per the fix-PR rule, this PR edits component:Calendar (now on main): FR5 says a borrowed adjacent-month day is aria-disabled, cannot be picked, and the keyboard skips it; AR1's remaining gap (arrows, Home and End focusing a borrowed day) is deleted — the gap list is now empty — and the verification row cites "skips borrowed adjacent-month days and crosses into their month instead" and "in a two-month view an arrow from the first month lands on the real day, never a borrowed one". Stacked on #7467, which removes the Page-key and two-month gaps.

Writing rubric results

R1 narration: none; FR5 and AR1 stay present tense.
R2 research: none in the record.
R3 evidence: the AR1 verification cell cites test titles, not this pull request.
R4 rejected alternatives: none added.
R5 change references: one #2715 inside a verbatim quoted test title (as in #7467), left as the test names itself.
R6 open questions: unchanged.

… into their month (#7478)

## Problem

A keyboard user arrowing through a Calendar could land on a borrowed adjacent-month day — shown dimmed and exposed `aria-disabled` — and then Enter or Space picked nothing. `useGridFocus`'s `isCellFocusable` read only native `disabled` (Calendar.tsx L803–804), and borrowed days are never natively disabled (a click on one navigates). `component:Calendar` FR5/AR1 (#7464) record this as an implementation gap under the Grid adoption.

## Fix

`isCellFocusable` excludes `[aria-disabled="true"]` buttons. The hook already continues past non-focusable cells in the same direction and, at the grid edge, calls `onNavigateBefore/After`, so the month navigates and the pending focus lands on the real day in the month now shown — the behaviour FR5 describes. A borrowed day's click is inert (Calendar.tsx L1167 guards on `effectivelyDisabled`); pointer focus on one is still possible, which is why the Page-key fix keeps its from-a-borrowed-day clamp.

## Stacked on the Page-key fix

Base branch: `fix/calendar-page-keys` (#7467), whose per-grid pending-focus rule (only the grid showing the target month acts) this fix depends on in a two-month view. New here: an arrow leaving one grid toward a day another grid already shows moves focus there **without paging** (January 28 → ArrowDown → February 4 in the second grid, view unchanged), while a target outside both grids pages and focuses the real day (February 24 → ArrowDown → March 3). Test: "in a two-month view an arrow from the first month lands on the real day, never a borrowed one" (`numberOfMonths={2}`).

## Evidence

- `Calendar.test.tsx` "skips borrowed adjacent-month days and crosses into their month instead": ArrowLeft from January 1, 2026 announces December 2025 and focuses the real December 31 (not aria-disabled). Red arm: fails with `Calendar.tsx` reverted to main (focus went to the borrowed copy).
- Two existing cross-month tests ("ArrowDown moves focus +7 days…", "…locale-safe") rendered a controlled Calendar whose `onFocusDateChange` was a mock, so they passed only by focusing the borrowed February copy; they now use an owner that follows the focus date and assert the real February 4. Both fail on main's Calendar with the new assertions.
- Calendar + DateInput suites 509/509; tsc, eslint, Prettier clean.

## Changeset

`@astryxdesign/core` patch `[fix]`.

## Record

Per the fix-PR rule, this PR edits `component:Calendar` (now on `main`): FR5 says a borrowed adjacent-month day is `aria-disabled`, cannot be picked, and the keyboard skips it; AR1's remaining gap (arrows, Home and End focusing a borrowed day) is deleted — the gap list is now empty — and the verification row cites "skips borrowed adjacent-month days and crosses into their month instead" and "in a two-month view an arrow from the first month lands on the real day, never a borrowed one". Stacked on #7467, which removes the Page-key and two-month gaps.

## Writing rubric results

R1 narration: none; FR5 and AR1 stay present tense.
R2 research: none in the record.
R3 evidence: the AR1 verification cell cites test titles, not this pull request.
R4 rejected alternatives: none added.
R5 change references: one `#2715` inside a verbatim quoted test title (as in #7467), left as the test names itself.
R6 open questions: unchanged.
@vercel

vercel Bot commented Oct 14, 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 Oct 14, 2026 3:57am UTC

Request Review

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

astracat-bot Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 14, 2026, 4:22 AM UTC

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec d30de8a

@github-actions

github-actions Bot commented Oct 14, 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 1642 -
Complexity N/A Very High (171) -

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

44 of 448 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
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 754,077
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,188
Chat Full AI Chat probe light 238,081
Chat Full AI Chat probe dark 237,048
Markdown Default probe light 159,625
Markdown Default probe dark 158,986
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
Chat Default neutral dark 33,205
Chat Default neutral light 32,876
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,406
Chat With Attachments probe dark 11,232
ProgressBar With Target Mark probe dark 7,895
ProgressBar With Target Mark probe light 7,895
TableRowExpansion Detail Panel neutral dark 5,150
TableRowExpansion Detail Panel neutral light 4,068

and 24 more.


Generated by PR Enrichment workflow | Storybook | Sandbox | 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.

Recommending approval: the arrow keys now pass over the dimmed adjacent-month days and land on the real day — in the other grid of a two-month view without paging, or in the newly shown month — and Home and End stop at the month's own days, as the release note says. Five of the new and updated tests fail without the change and pass with it, and the Calendar, date-input and grid suites, typecheck, lint, format and CI all pass. Nothing else is needed; a dedicated Home/End test would be welcome hardening but is optional.

[Automated review]

@cixzhang
cixzhang merged commit d21d77c into main Oct 14, 2026
55 checks passed
@github-actions
github-actions Bot deleted the fix/calendar-skip-outside-days-reland branch October 14, 2026 06:22

This branch was successfully deployed

1 active deployment
Preview — d30de8a4 Deployed Oct 14, 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.

1 participant