Repository navigation
fix(Calendar): arrow keys skip borrowed adjacent-month days and cross into their month - #7511
Conversation
… 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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec d30de8a |
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewModified ComponentsCalendar (@astryxdesign/core) · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Visual Regression44 of 448 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 24 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
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]
Re-land of #7478, which merged into a stale base (
fix/calendar-page-keys, #7467's branch, after GitHub had not yet retargeted it tomain). This PR carries exactly #7478's change — its final head e8f17e4's four files on top ofmain@ 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'sisCellFocusableread only nativedisabled(Calendar.tsx L803–804), and borrowed days are never natively disabled (a click on one navigates).component:CalendarFR5/AR1 (#7464) record this as an implementation gap under the Grid adoption.Fix
isCellFocusableexcludes[aria-disabled="true"]buttons. The hook already continues past non-focusable cells in the same direction and, at the grid edge, callsonNavigateBefore/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 oneffectivelyDisabled); 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 withCalendar.tsxreverted to main (focus went to the borrowed copy).onFocusDateChangewas 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.Changeset
@astryxdesign/corepatch[fix].Record
Per the fix-PR rule, this PR edits
component:Calendar(now onmain): FR5 says a borrowed adjacent-month day isaria-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
#2715inside a verbatim quoted test title (as in #7467), left as the test names itself.R6 open questions: unchanged.