Repository navigation
fix(Calendar): PageUp and PageDown move the focused day by a month - #7467
Conversation
A page navigated the visible month but moved the focused day by seven days, so focus landed in the wrong month (component:Calendar AR1, APG grid). The month navigation now takes a unit: an arrow crossing the month edge keeps its day offset, a page moves by whole months with the day of the month kept where it exists. Red-armed test.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
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.
Approval is on hold: no current spec on main governs how PageUp/PageDown move Calendar's focused day (the month-paging rule exists only as the draft component:Calendar AR1 proposed in #7464), so a maintainer needs to provide or identify that governing claim before this can ship as a [fix]. Independently of that decision, two things need changing:
- With
numberOfMonths={2}, PageDown/PageUp from a day in the first visible month still land on the wrong day (January 15 goes to March 1, or to the December 28 outside day), because the second month grid's pending-focus fallback overrides the first grid's correct target, so please fix that and cover the two-month case in a test. NavigationUnitwas inserted between the existing JSDoc comment andexport interface CalendarHandle, so the exportedCalendarHandlelost its doc comment.
[Automated review]
| const targetPd = | ||
| unit === 'months' | ||
| ? plainDateAddMonths(currentPd, delta) | ||
| : plainDateAddDays(currentPd, delta * (offset ?? 7)); |
There was a problem hiding this comment.
With numberOfMonths={2}, this target is right but focus does not stay on it when paging from the first visible month: PageDown from January 15 ends on March 1, and PageUp from January 15 ends on the December 28 outside day in the January grid. Every rendered MonthGrid runs the pending-focus effect and falls back to its own first enabled day when the target is not in it, so the second grid overrides the first. Consider resolving the pending target once (only the grid whose month contains it focuses it, and only one grid falls back when no visible month does), and add a two-month PageUp/PageDown test that starts in the first month.
| /** How a month navigation moves the focused day: by its row offset in days, or by whole months. */ | ||
| type NavigationUnit = 'days' | 'months'; |
There was a problem hiding this comment.
Inserting NavigationUnit here moves the existing /** Imperative handle for Calendar handleRef */ comment onto this private type, so the exported CalendarHandle loses its doc comment. Declaring NavigationUnit above that comment, or after CalendarHandle, keeps it attached.
…ending focus With two months, every grid ran the pending-focus effect and the grid without the target fell back to its own first day, overriding the right one. The grid whose month matches the target now acts alone, skips outside and disabled copies, and falls back to that month's first enabled day. The NavigationUnit alias moves above CalendarHandle's doc comment, which it had displaced. Two-month paging covered by a red-armed test.
There was a problem hiding this comment.
Approval is on hold until a maintainer provides a current spec on main for how PageUp/PageDown move Calendar's focused day: the month-paging rule exists only as the draft component:Calendar AR1 in #7464 (which relies on spec:AST-020 FR15 in #7458), so that claim needs to land as current authority, or another current record must state it, before this ships as a [fix]. This revision fixes the two-month paging and the CalendarHandle doc comment, but two things still need changing:
- With focus on an outside day (for example after Home on the first week), PageUp or PageDown now drops focus to the page body, and the never-cleared target later pulls focus back when the header buttons show its month, so the next Enter selects that day; please resolve or clear a target that no visible month contains and cover it with a test.
- The changeset says arrow keys crossing a month edge are unchanged, but arrow crossings from the first of two months now land on a different (correct) day.
[Automated review]
| ); | ||
|
|
||
| const targetPd = plainDateFromISO(pendingFocus); | ||
| if (targetPd.year !== year || targetPd.month !== month.month) { |
There was a problem hiding this comment.
When no visible month contains the pending target, every grid returns here and nothing clears it. That happens whenever a Page key starts on an outside day (Home on the first week row, then PageDown): focus drops to the page body, and when the header's Previous or Next button later shows the target's month, this effect moves focus onto that day, so the next Enter selects it. Consider letting exactly one grid fall back (and clear pendingFocus) when the target is in no visible month, or deriving the Page target from the grid's month, plus a test that pages from an outside day.
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [fix] `Calendar`: PageUp and PageDown now move the focused day by a month — into the month the grid shows, on the same day of the month where it exists — instead of by a week. Arrow keys crossing a month edge are unchanged. |
There was a problem hiding this comment.
"Arrow keys crossing a month edge are unchanged" is no longer accurate: with two months, ArrowUp from January 2 now focuses December 26 in the December grid, where it used to land on the December 28 outside copy in the January grid. Worth saying that two-month cross-month focus now lands on the computed day.
…month now shown Paging from a borrowed day (Dec 28 in January's first row) targeted a month no grid shows, so focus fell to the page body and the never-cleared target later pulled focus back. The page target is pulled into the nearest visible month, keeping its day of the month. Changeset describes the two-month arrow crossing too. Red-armed test.
There was a problem hiding this comment.
Approval is on hold until a maintainer provides or identifies a current spec on main for how PageUp/PageDown move Calendar's focused day: the month-paging rule exists only as the draft component:Calendar AR1 in #7464 (which relies on spec:AST-020 FR15 in #7458), so that claim needs to land as current authority, or another current record must state it, before this ships as a [fix]. This revision fixes paging from a borrowed adjacent-month day, but three things still need changing:
- At a
min/maxboundary, an arrow key that leaves the month (for example ArrowRight from themaxday) leaves a pending target that pulls focus back into the grid once the Previous/Next month button shows that month, so the next Enter selects a day; please resolve or clear every pending target and add boundary tests. - PageUp/PageDown into a month with no enabled day now drops focus to the page body, where the released code kept it in the grid.
- The Changeset says focus from a borrowed day used to drop to the page, but the released code landed on the month's first day.
[Automated review]
| if (targetPd.year !== year || targetPd.month !== month.month) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
When an arrow key leaves the month because every remaining day in that direction is disabled (ArrowRight from the max day, ArrowLeft from the min day), navigateMonth targets a day still in the old month, since the visible-month clamp only covers 'months'. No grid shows that month, so every grid returns here and pendingFocus is never cleared; when the Previous/Next month button later shows that month, focus moves onto its first enabled day and the next Enter selects it (WithDateConstraints: ArrowRight from January 25, activate Previous month, and the next Enter selects January 10). Clamping every unit into the visible months, or letting exactly one grid fall back and clear the target, plus clearing pendingFocus on header navigation, would close this.
| } | ||
| const buttons = Array.from( | ||
| gridRef.current.querySelectorAll<HTMLElement>( | ||
| 'button[data-date]:not([disabled]):not([aria-disabled="true"])', |
There was a problem hiding this comment.
With adjacent-month copies excluded here, a page into a month that has no enabled day (PageUp from January 15 with min January 10) leaves targetButton null, so focus drops to the page body and the opposite Page key no longer brings the user back; the released code kept focus on an adjacent-month copy. Keeping focus in the grid when the month has no enabled day, or not moving past min/max by keyboard as the header buttons already refuse to, would avoid the loss.
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [fix] `Calendar`: PageUp and PageDown move the focused day by a month — into the month the grid shows, on the same day of the month where it exists — instead of by a week; from a borrowed adjacent-month day the target is pulled into the month now shown instead of dropping focus to the page. With two months, a page or an arrow crossing a month edge from the first month now lands on the correct day (the second grid no longer overrides the first grid's target). |
There was a problem hiding this comment.
“instead of dropping focus to the page” describes this branch's previous revision rather than the release: the released code lands a page from the borrowed December 28 on February 1. Describing the change against the release (for example “instead of the month's first day”) keeps the declaration accurate.
…ng target; a page into a month with no enabled day keeps focus in the grid Red-armed: ArrowRight from the max day no longer arms a target that a later Next click pulls focus toward; PageDown into an all-disabled month focuses the first day button that can still take focus instead of the page body. Changeset describes the released from-a-borrowed-day behaviour accurately.
There was a problem hiding this comment.
Approval is on hold until a maintainer makes the governing spec for this change current on main: the month-paging rule it implements is the draft component:Calendar AR1 in #7464, which also still needs to settle where a Page key pressed on a borrowed adjacent-month day lands (this change keeps PageUp from the borrowed December 28 on December 28 and sends PageDown to February 28). Independently of that decision, two keyboard-focus defects need fixing:
- When
dateConstraintsdisable every remaining day in an arrow's direction (for example ArrowLeft from January 10 with days before it disallowed), focus drops to the page and a pending target survives, so a later Previous/Next month click pulls focus into the grid and the next Enter selects a day the user never chose; please resolve or clear every pending target, not only Page ones, and test that edge. - The new
min/maxguard checks whether the visible months can move rather than whether the target day is past the bound, so in a two-month calendar that already shows a bound, ArrowUp from February 3 no longer reaches January 27 and PageDown from January 15 does nothing although February 15 is visible; please block only targets outside the bounds and add two-month boundary tests.
[Automated review]
| if ( | ||
| (delta < 0 && !canNavigatePrevious) || | ||
| (delta > 0 && !canNavigateNext) | ||
| ) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
This asks whether the visible months can move, not whether the target day is past min/max. In a two-month calendar that already shows a bound (DateRangeInput's default layout), the target is often in the other visible grid: with min January 1 and max February 28, ArrowUp from February 3 no longer reaches January 27, and PageDown from January 15 does nothing although February 15 is visible and enabled. Returning only when the target itself is outside the bounds, and setting the pending focus without moving the month when the target is already visible, would keep the boundary rule without blocking these moves.
| ); | ||
|
|
||
| const targetPd = plainDateFromISO(pendingFocus); | ||
| if (targetPd.year !== year || targetPd.month !== month.month) { |
There was a problem hiding this comment.
A day-offset target can still fall in a month no grid shows: when dateConstraints (or hidden outside days) disable every remaining cell in an arrow's direction, useGridFocus pages the month and navigateMonth targets a day in the old month, which neither the 'months'-only clamp nor the new min/max guard covers. Every grid returns here, focus stays on the page body and pendingFocus is never cleared, so a later Previous/Next month click moves focus onto that month's first enabled day and the next Enter selects it (with dateConstraints={[d => d >= new Date(2026, 0, 10)]}: ArrowLeft from January 10, Next month, Enter selects January 10). Clamping every unit into the visible months, or letting exactly one grid fall back and clear the target, plus clearing pendingFocus on header navigation, would close it.
… this fix closes; AR1 cites the Page-key tests
|
/approve-spec 329b5a5 |
There was a problem hiding this comment.
Approval is on hold until a maintainer makes the governing spec for this change current on main: component:Calendar landed as a draft record, so its PageUp/PageDown rule (AR1), including where a page from a borrowed adjacent-month day lands, needs to become authority: current, or another current record must state it. Independently of that decision, two keyboard-focus defects still need fixing:
- When
dateConstraintsdisable every remaining day in an arrow's direction (for example ArrowLeft from January 10 with earlier days disallowed), focus drops to the page and the pending target survives, so a later Previous/Next month click moves focus into the grid and the next Enter selects a day the user never chose; please resolve or clear every pending target and test that edge. - The new
min/maxguard checks whether the visible months can move rather than whether the target is past a bound, so in a two-month calendar that already shows a bound, ArrowUp from February 3 no longer reaches January 27 and PageDown from January 15 does nothing although February 15 is visible; please block only out-of-range targets and add two-month boundary tests.
[Automated review]
…y out-of-range targets, and a direction with no enabled day left changes nothing navigateMonth resolves the target before touching the month: an arrow walks its direction to the first enabled day (within a year) and stops with no change when it meets min/max or runs out of enabled days; a page keeps its same-day target, pulls it into the months that will show, and stops when that target is past min/max. The months change only when the target is not already shown, so ArrowUp from February 3 reaches January 27 in a two-month view at a January minimum, and PageDown from January 15 reaches a visible February 15 without paging. The root reads the grids' constraint view through useCalendarConstraints. Record: AR1 states the rule; verification cites the two new tests.
|
/approve-spec c5e27be |
There was a problem hiding this comment.
Thanks — the Page-key, min/max and two-month focus behaviour now match the Calendar record as approved, and CI is green, but one small regression needs fixing before this can merge. The new firstEnabledDayOfMonth helper sits between Calendar's doc comment and export function Calendar, so the published Calendar.d.ts and the Storybook docs page lose the component's description; please move the helper above that comment or below the component. While there, AR1's “a key whose target lies past min or max changes nothing” also reads on Home and End, which still move to the nearest enabled day of the week, so scoping it to arrows and Page keys, as the Changeset words it, would keep the record accurate.
[Automated review]
| * <Calendar value={selectedDate} onChange={setSelectedDate} /> | ||
| * ``` | ||
| */ | ||
| /** The first day of `month`'s month that `isDisabled` allows, or null. */ |
There was a problem hiding this comment.
This helper now sits between Calendar's doc comment (L226–233) and export function Calendar, so the comment no longer attaches to the component: the built Calendar.d.ts declares Calendar with no description, and Storybook's docgen description for it is empty. Moving the helper above the /** A calendar component … */ block (for example next to NavigationUnit) or below the component restores it.
| same direction, crossing the month edge when it must; a key whose target | ||
| lies past `min` or `max` changes nothing and keeps focus where it is, and |
There was a problem hiding this comment.
“A key whose target lies past min or max changes nothing” also covers Home and End, whose targets (L142) are the first and last day of the week, but useGridFocus sends them to the first or last enabled day of the week: with min on Wednesday January 7, Home from January 8 focuses January 7. Scoping the clause to arrows and Page keys, as the Changeset words it, would keep the record accurate.
…endar keeps its JSDoc; AR1 says enabled day of the week and arrow-or-Page past min/max
|
/approve-spec 1f5ab63 |
There was a problem hiding this comment.
Thanks — the Page-key, min/max and two-month focus behaviour now matches the Calendar record, Calendar has its doc comment back, and CI is green, but one focus regression needs a fix before this can merge. When focusDate is controlled and its owner does not apply the month a key asks for (for example onFocusDateChange={() => {}}), a page or month-crossing arrow now leaves its target pending, so when the owner later shows that month, focus jumps from wherever the user is onto that day and the next Enter selects a date they never chose: PageDown from January 15, focus another control, then show February, and focus lands on February 15. Please drop a pending target that the render after the key does not show, or that would apply after focus has left the calendar, and add a test for this controlled case.
[Automated review]
| if (targetPd.year !== year || targetPd.month !== month.month) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
With a controlled focusDate whose owner does not apply the requested month (for example onFocusDateChange={() => {}}), no grid shows the target's month, so every grid returns here and nothing clears pendingFocus. When the owner later shows that month, this Effect moves focus from wherever the user is onto the old target, and the next Enter selects it: PageDown from January 15, focus another control, the owner shows February, and focus lands on February 15, where Enter calls onChange('2026-02-15'); the released code left focus alone. Dropping the target when the render after the key does not show its month, or when focus has left the calendar before it would apply, plus a test for this controlled case, would close it.
…its month and dies when focus leaves; the target becomes the grid's Tab stop A controlled owner that refuses the month change left the target pending; when that month appeared later it stole focus and Enter. Grids now receive the target only while a rendered month can claim it, and focus leaving the calendar drops it. The pending-focus effect also makes the target the grid's one tabindex=0 before focusing it (FR2), as the hook's own arrow moves do.
… it); red before the stop move
|
/approve-spec 14a7d71 |
…day grid; test with an owner that allows via rerender
|
/approve-spec 4978a64 |
There was a problem hiding this comment.
Thanks: PageUp and PageDown now move the focused day by a month, the two-month, min/max and constraint cases land where the Calendar record describes, and CI is green, but one narrow focus issue needs a fix before this can merge. With a controlled focusDate whose owner declines a page, a later arrow inside the grid does not cancel the pending target: in two months, decline PageDown from February 10, press ArrowRight to February 11, then show February–March, and focus jumps to March 10, where Enter would select it. Please keep the pending target only while focus moves to the target day itself (for example by checking relatedTarget's data-date against it), update the comment that says the target lives one render, and add a test for this sequence.
[Automated review]
| e.relatedTarget instanceof Element && | ||
| e.currentTarget.contains(e.relatedTarget) && | ||
| e.relatedTarget.closest('[role="grid"]') != null; | ||
| if (pendingFocus != null && !staysOnDayGrid) { |
There was a problem hiding this comment.
A move inside the day grid does not supersede a declined page's target, because any day-grid relatedTarget keeps it. With two months and a controlled focusDate whose owner declines the page: PageDown from February 10, ArrowRight to February 11, then the owner shows February–March, and focus jumps from February 11 to March 10, where Enter would select it. Keeping the target only while focus moves to the target day itself, e.g. e.relatedTarget.getAttribute('data-date') === pendingFocus instead of the [role="grid"] test, closes this; with that change the Calendar and date-field suites still pass, and a target with no intervening move still lands when its month appears. The comment above (“lives exactly one render”) should describe the lifetime too, and a test for this sequence would pin it.
…7509) ## What changes for users A screen-reader user reading a `Calendar` with `hasWeekNumbers` no longer meets a stray unnamed cell at the start of the weekday header row: the blank corner above the week-number column is now a `columnheader` named with the locale's own word for the week field ("week", "Woche", "週" — from CLDR, rendered as visually hidden text so the column stays blank), so every cell in the header row has a grid role and the row's column count matches the week rows below it. ## Authority Path (a): `spec:AST-020` FR15 (current) plus the owner's 2026-10-13 APG adoption approval. APG Grid requires every cell in a `row` to be a `gridcell`, `columnheader` or `rowheader`; `component:Calendar` FR1 names the grid structure. A named `columnheader` is what the `rowheader` column it tops implies (the APG uses header roles for header cells; `presentation` would remove the cell from the grid's column model). ## Shape - `Calendar.tsx`: the corner cell gets `role="columnheader"` and a `<VisuallyHidden>` child with `plainDateWeekFieldName(locale)` (text content, not `aria-label`, so axe's `empty-table-header` passes). - `utils/plainDate.ts` (an approved raw-`Intl` file under `no-raw-intl-locale`): `plainDateWeekFieldName(locale)` reads `Intl.DisplayNames(locale, {type: 'dateTimeField'}).of('weekOfYear')` — Chrome 106 / Safari 15.4 / Firefox 110, inside the Baseline − 2 tier — with the English CLDR value as the fallback. Not re-exported from the package. No new locale catalog key. - `Calendar.test.tsx`: "with week numbers, the header row's corner cell is a named columnheader, so every row child is a grid cell" — red on `main`, green here. `plainDate.test.ts`: `plainDateWeekFieldName` returns "week"/"Woche" and is never empty. - Record: FR1 names the week-number header cell; the FR1–FR5 verification row cites the new test. No gap sentence was on `main` for this, so none is deleted. - Changeset (patch). ## Order Queued after #7467 and #7478 (same component; independent files but the record's FR1–FR5 row is shared). When this merges after #7499, that binding's `single-week-numbers` known failure becomes an unexpected pass and is emptied there. ## Writing rubric results R1 narration: none; FR1 stays present tense. R2 research: none in the record. R3 evidence: the 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 already in the row, left as the test names itself. R6 open questions: unchanged.
…target; merge main (#7509 week-number header)
…e; red under the grid-stays rule
|
/approve-spec ca77411 |
There was a problem hiding this comment.
Thanks: PageUp and PageDown now move the focused day by a month, the two-month, min/max, empty-month and constraint cases land where the Calendar record describes, a declined page's target is now dropped by any move to another day, and CI is green, so this review has no remaining changes to request. Optionally, the record's AR1 verification row could also name the five new tests it does not list yet (the two-month landing, the three refused-target tests and the Tab-stop test).
[Automated review]
… 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.
… into their month (#7511) **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.
## What this proves `component:Calendar` AR1 (the Grid adoption recorded in `component:Calendar`, now on `main`, under `spec:AST-020` FR15) has an executable contract and a binding. A keyboard or screen-reader user in a Calendar month gets: a named grid whose rows are rows of gridcells (with a column-header row), one Tab stop per grid, selected days exposed as selected (and the grid marked multi-selectable in range mode), the arrows moving one cell at a time in reading order, Home/End to the ends of the week row, and Enter picking the focused day. Test-only: no runtime, docs, or Changeset. Enforcement follows `spec:AST-020` FR9: the APG Grid's required parts are `required`; Enter's default action (author-determined in APG, defined by the record) is `advisory` until `component:Calendar` is current. ## Expectations (AST-020 FR13) | Expectation | Sources | Layer | Enforcement | | --- | --- | --- | --- | | `grid.container.role-and-name` | WCAG 4.1.2, APG Grid, APG Grid | accessibility-tree | required | | `grid.structure.rows-and-cells` | WCAG 1.3.1, APG Grid | dom | required | | `grid.focus.single-tab-stop` | WCAG 2.1.1, WCAG 2.4.3, APG Grid | dom | required | | `grid.selection.exposed` | WCAG 4.1.2, APG Grid, WAI-ARIA 1.2 | dom | required | | `grid.keys.arrows` | WCAG 2.1.1, APG Grid | real-browser | required | | `grid.keys.home-end` | WCAG 2.1.1, APG Grid | real-browser | required | | `grid.keys.enter-activates` | WCAG 2.1.1, `component:Calendar` AR1 | real-browser | advisory | Exemptions: `1.1.1-non-text-content` → the binding component and caller content; `1.3.1-info-and-relationships` → the binding component (remainder only); `1.3.2-meaningful-sequence` → the binding component; `1.3.5-identify-input-purpose` → not applicable; `1.4.1-use-of-color` → the binding component and theme; `1.4.3-contrast-minimum` → the binding component and theme; `1.4.11-non-text-contrast` → the binding component and theme; `2.1.1-keyboard` → the binding component and composing page (remainder only); `2.1.2-no-keyboard-trap` → the binding component and composing page; `2.4.2-page-titled` → the page; `2.4.3-focus-order` → the composing page (remainder only); `2.4.4-link-purpose` → not applicable; `2.4.6-headings-and-labels` → the binding component and caller content (remainder only); `2.4.7-focus-visible` → the binding component and theme; `2.4.11-focus-not-obscured` → the composing page; `2.5.2-pointer-cancellation` → the binding component; `2.5.3-label-in-name` → the binding component; `2.5.8-target-size` → the binding component and theme; `3.1.1-language-of-page` → the page; `3.2.2-on-input` → the caller and composing page; `3.2.4-consistent-identification` → the composing page; `3.3.1-error-identification` → the binding component; `3.3.2-labels-or-instructions` → the binding component and caller content; `4.1.2-name-role-value` → the binding component (remainder only); `4.1.3-status-messages` → the binding component and the assistive-technology verification record, spec:AST-009; `apg-interaction` → the binding component's record (remainder only); `forced-colors` → the binding component and theme; `reduced-motion` → the binding component and theme; `at-facing-strings` → the binding component ## Known failures None: the week-numbers corner-cell gap this binding first recorded was fixed on `main` by #7509 before this binding merged, so its row was emptied; every state passes every applicable expectation in jsdom and Chromium. ## Shape - `internal/a11y-spec/src/patterns/grid.ts` — `GRID_PATTERN`, 7 expectations whose sources say what their pages say: APG Grid for roles, rows, naming, selection and the data-grid Tab/arrow/Home/End text (verified against the published pattern on 2026-10-13); WAI-ARIA 1.2 for `aria-multiselectable`; `component:Calendar` AR1 (pinned) for Enter/Space picking the focused day, which the APG leaves author-determined; every other checklist dimension exempted to a named owner with a verification method. Structure counts use the new `Subject.descendantCount(selector)`. - `grid.fixtures.ts` — a 3×3 HTML grid whose `<script>` implements the roving-tabindex data-grid model; every expectation has at least one violating twin (`GRID_MUTATIONS`, 10 mutations). - `grid.jsdom.test.ts` (24 cases) and `grid.chromium.spec.ts`. - `internal/a11y-spec/src/harness.ts` + `harness/{jsdom,chromium}.ts` — `Subject.descendantCount`; (`Home`/`End` keys came in with the Slider contract.) - `packages/core/src/Calendar/__tests__/Calendar.a11y.{states,renders,test}.tsx` and `Calendar.a11y.chromium.spec.ts` — four states, each starting on January 14, 2026 with a full in-month neighbourhood: single with January 20 selected; the same under RTL (ArrowLeft moves to the next day); single with `hasWeekNumbers` (its corner-cell header, fixed by #7509); a two-month range (January 20–22) with the first grid as the subject (Enter starts a new range there, so the activation row does not apply). Related subjects: `start`, `startCell`, `next`, `previous`, `below`, `above`, `rowStart`, `rowEnd`. - `apps/storybook/stories/CalendarGridA11y.stories.tsx` — one `no-visual` story per state through `renderCalendarState`. - `.github/workflows/ci.yml` — "Run Grid accessibility contract" step; scope through `pr-scope-touches.sh` from the base; runs when Calendar, `useGridFocus`, the harness, the stories, or the contract change. - README row and index export. ## Source lines behind the binding facts `role="grid"` + `aria-label={monthLabel}` + `aria-multiselectable` in range mode (Calendar.tsx L888–892); header `role="row"` of `columnheader`s (L901–913); week `role="row"`s of `role="gridcell"`s (L927, L1112); roving `tabIndex` via `useGridFocus` with `hasRovingTabIndex` (L802–806); arrows/Home/End in `useGridFocus.ts`; Enter picks the focused day (`handleDayClick`, L432–448). ## Ownership exclusions `CALENDAR_EXCLUSIONS`: disabled-day arrow skipping (an arrow that meets a day disabled by bounds or a constraint skips it and continues — `component:Calendar` AR1's rule beyond the APG one-cell step; `Calendar.test.tsx` proves it, so the binding's states stay free of disabled days); month-edge crossing (`component:Calendar` FR5 — the APG grid stops at the edge, the record defines the crossing; every state starts mid-month); pointer selection (`Calendar.test.tsx`) and Page keys (owned by `Calendar.test.tsx`'s five Page-key cases from #7467, now on `main`). DateInput's month panes bind in their own change. ## Moved and retained local tests (AST-021 FR6, FR14) Moved into the binding: `Calendar.test.tsx` "sets aria-multiselectable=\"true\" on the grid in range mode" (→ `grid.selection.exposed` on the `range-two-months` state, same DOM layer). Retained: "sets aria-multiselectable on both grids in a two-month range view" (the second grid, which the binding does not subject) and "does not set aria-multiselectable in single mode" (cited by `component:Calendar` AR1); "has accessible grid structure" and "renders a valid APG grid: one grid, header row of columnheaders inside it, week rows of gridcells" (cited by AR1/FR1–FR5 — removal blocker: the record is `draft` and cites them; they come out with the record pass that makes it current); "with week numbers, the header row's corner cell is a named columnheader, so every row child is a grid cell" (the stray-child check that red-armed #7509; cited by FR1–FR5 — same blocker). ## Evidence - Vitest Calendar directory green (incl. 8 binding cases); pattern jsdom self-test 24/24; a11y-spec package tests green; tsc (core, a11y-spec, storybook), eslint, Prettier, use-client, visual-workflow-owner clean. - Real Chromium: the CI step on this PR runs the fixture self-test (conforming pass, every mutation fails) and the four binding states, with no known failures.
Problem
A keyboard user in a Calendar pressed PageDown: the grid showed the next month, but focus moved only seven days — often still in the old month, now off screen, or on the wrong day.
component:CalendarAR1 (APG Grid adoption) requires PageUp/PageDown to move the focused day by a month; the record names this as an implementation gap until this fix.Fix
Calendar.tsx:navigateMonthtakes a unit. Arrow keys crossing a month edge keep their day offset (unchanged); the Page handlers pass'months', so the focused day moves throughplainDateAddMonths, which keeps the day of the month where it exists (Jan 31 → Feb 28). The month grid'sonNavigatePrevious/onNavigateNextcarry the unit; nothing else changes.Evidence
Calendar.test.tsx: "moves the focused day by a month with PageDown and PageUp, into the month now shown" — from Jan 31, PageDown shows February and focuses February 28; PageUp shows January and focuses January 28. Red arm: withCalendar.tsxreverted to main the test fails (focus stayed a week away); with the fix 189/189 Calendar tests and 314/314 DateInput tests pass.Changeset
@astryxdesign/corepatch[fix].Record
component:CalendarAR1 names this gap in #7464.Record
Per the fix-PR rule, this PR edits
component:Calendar(now onmain): FR5 drops the two-month exception (the per-grid pending-focus rule makes a key land on the target in whichever grid shows it); AR1's gap list drops the Page-key gap and the two-month gap and keeps only the borrowed-day gap for #7478; the AR1 verification row cites the four Page-key tests this PR adds.Writing rubric results
R1 narration: none; FR5 and AR1 stay present tense (gap clauses deleted, not rephrased as history).
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
#2715appears inside a verbatim test title the verification row quotes ("caps the range highlight next to a disabled mid-range day (#2715)") — a title, not standing content; left as the test names itself.R6 open questions: unchanged.