An open source design system that's fully customizable and agent ready
TypeScript
fix(DateInput): the month scroller's arrows follow the reading direction and land on the real day (#7466)
Cindy Zhang50cda0046d71
diff --git a/.changeset/dateinput-month-scroller-keys.md b/.changeset/dateinput-month-scroller-keys.mdnew file mode 100644index 0000000000..4d6ad3b619--- /dev/null+++ b/.changeset/dateinput-month-scroller-keys.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[fix] The touch month scroller shared by `DateInput` and `DateTimeInput`: under RTL the horizontal arrows follow the reading direction (ArrowLeft moves to the next day, ArrowRight to the previous), and every keyboard move — arrows and Home/End — now lands on the real day in its own month pane rather than on the dimmed, disabled copy a neighbouring pane shows at its edge. Touch scrolling is unchanged.++@cixzhangdiff --git a/packages/core/src/DateInput/DateInput.spec.md b/packages/core/src/DateInput/DateInput.spec.mdindex 5b6f929377..b476a678f5 100644--- a/packages/core/src/DateInput/DateInput.spec.md+++ b/packages/core/src/DateInput/DateInput.spec.md@@ -218,10 +218,8 @@ approved policy.`aria-selected` on the chosen day; ArrowLeft and ArrowRight move by a dayfollowing the reading direction, ArrowUp and ArrowDown by a week, Home and Endto the ends of the week, PageUp and PageDown by a month, and Enter or Space- picks the focused day. Implementation gaps: the horizontal arrows do not follow- the reading direction under RTL; PageUp/PageDown do not page by a month; and- a keyboard move can land on a neighbouring pane's dimmed, `aria-disabled` copy- of the target day instead of the real day in its own pane.+ picks the focused day. Implementation gap: PageUp/PageDown do not page by a+ month.## Design relationships@@ -282,17 +280,17 @@ the shared `input-clear-icon` target owns current clear-glyph theming.## Verification map-| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |-| ---------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------- |-| FR1, FR5–FR8, FR10–FR12; AR1–AR4 | `DateInput.test.tsx` | empty, valued, typing, invalid, constrained, open, disabled, busy, clear, status, grouped | Value, callbacks, ARIA, disabled guard, focus, or shared-field composition drifts | `audit:DateInput/pointer-field` |-| FR2–FR4 | `Presentation.test.tsx`, `NativeDateField.test.tsx`, `DateInputTouch.test.tsx` | every presentation, omitted props, every deprecated mapping, dual props, fine/coarse, touchscreen laptop | A value resolves to the wrong surface, width affects modality, or legacy behavior wins incorrectly | `audit:DateInput/presentation` |-| FR5–FR7; AR1, AR3–AR5 | `NativeDateField.test.tsx` | empty, valued, focused, constrained, disabled, clear, formatted, locale | Native commit, overlay, label, constraint, or focus reconciliation drifts | `audit:DateInput/native` |-| FR1, FR4–FR7, FR9, FR11–FR12; AR1, AR4, AR6; PR1–PR2 | `DateInputTouch.test.tsx` | closed/open, month grid, selection correction, wheels, bounds, keyboard, swipe, mouse drag, clear, busy | Touch value parity, bounded rendering, focus, semantics, or gesture ownership drifts | `audit:DateInput/touch` |-| FR2–FR3, FR6 | `DateInput.doc.mjs`, Storybook controls, `scripts/check-knowledge.mjs` | five presentation values, deprecated prop, named formats, English and Chinese docs | Source, docs, types, or default mappings disagree | `audit:DateInput/docs-api` |-| Theming anatomy | `DateInput.test.tsx`, `themingTargets.test.ts`, generated probe theme | root size/status/disabled, toggle state, shared clear target | Target class or state is missing, undocumented, or placed on the wrong element | `audit:DateInput/theming` |-| FR8; AR2 | `apps/storybook/stories/DateInput.stories.tsx`, component-scoped axe | open Calendar dialog plus closed field states | Important popup semantics stay unreachable to the browser audit | `audit:DateInput/a11y` |-| AR7 | `apps/storybook/rtl-audit/targets.json`, component RTL audit | calendar and clear controls in LTR and RTL | DateInput-owned controls fail to exchange logical inline order | `audit:DateInput/rtl` |-| AR8 | `DateInputTouch.test.tsx` calendar-surface suite ("mounts a window of months around the visible one, not the whole century" for the named grids, "moves keyboard focus by date, across the month boundary", "moves a week at a time with the vertical arrows", "leaves exactly one day per month tab-reachable", "gives a spilled date no tab stop in the pane that borrows it", "disables days outside min/max and refuses to commit them"); ArrowLeft and ArrowUp (the suite presses only ArrowRight and ArrowDown on the month grid), RTL mirroring, Home/End, Page and activation keys under the Grid accessibility contract (`internal/a11y-spec`, pending) | LTR and RTL; month boundary; selected day; today | A day loses its gridcell role or selection, two days in one pane hold a Tab stop, or an arrow, Home/End, Page or activation key stops moving or picking | `audit:DateInput/accessibility` |+| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |+| ---------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------- |+| FR1, FR5–FR8, FR10–FR12; AR1–AR4 | `DateInput.test.tsx` | empty, valued, typing, invalid, constrained, open, disabled, busy, clear, status, grouped | Value, callbacks, ARIA, disabled guard, focus, or shared-field composition drifts | `audit:DateInput/pointer-field` |+| FR2–FR4 | `Presentation.test.tsx`, `NativeDateField.test.tsx`, `DateInputTouch.test.tsx` | every presentation, omitted props, every deprecated mapping, dual props, fine/coarse, touchscreen laptop | A value resolves to the wrong surface, width affects modality, or legacy behavior wins incorrectly | `audit:DateInput/presentation` |+| FR5–FR7; AR1, AR3–AR5 | `NativeDateField.test.tsx` | empty, valued, focused, constrained, disabled, clear, formatted, locale | Native commit, overlay, label, constraint, or focus reconciliation drifts | `audit:DateInput/native` |+| FR1, FR4–FR7, FR9, FR11–FR12; AR1, AR4, AR6; PR1–PR2 | `DateInputTouch.test.tsx` | closed/open, month grid, selection correction, wheels, bounds, keyboard, swipe, mouse drag, clear, busy | Touch value parity, bounded rendering, focus, semantics, or gesture ownership drifts | `audit:DateInput/touch` |+| FR2–FR3, FR6 | `DateInput.doc.mjs`, Storybook controls, `scripts/check-knowledge.mjs` | five presentation values, deprecated prop, named formats, English and Chinese docs | Source, docs, types, or default mappings disagree | `audit:DateInput/docs-api` |+| Theming anatomy | `DateInput.test.tsx`, `themingTargets.test.ts`, generated probe theme | root size/status/disabled, toggle state, shared clear target | Target class or state is missing, undocumented, or placed on the wrong element | `audit:DateInput/theming` |+| FR8; AR2 | `apps/storybook/stories/DateInput.stories.tsx`, component-scoped axe | open Calendar dialog plus closed field states | Important popup semantics stay unreachable to the browser audit | `audit:DateInput/a11y` |+| AR7 | `apps/storybook/rtl-audit/targets.json`, component RTL audit | calendar and clear controls in LTR and RTL | DateInput-owned controls fail to exchange logical inline order | `audit:DateInput/rtl` |+| AR8 | `DateInputTouch.test.tsx` calendar-surface suite ("mounts a window of months around the visible one, not the whole century" for the named grids, "moves keyboard focus by date, across the month boundary", "moves a week at a time with the vertical arrows", "leaves exactly one day per month tab-reachable", "gives a spilled date no tab stop in the pane that borrows it", "disables days outside min/max and refuses to commit them", "follows the reading direction under RTL: ArrowLeft moves to the next day", "moves keyboard focus by date, across the month boundary" (the real day, not the spill copy)); ArrowUp, Home/End, Page and activation keys under the Grid accessibility contract (`internal/a11y-spec`, pending) | LTR and RTL; month boundary; selected day; today | A day loses its gridcell role or selection, two days in one pane hold a Tab stop, or an arrow, Home/End, Page or activation key stops moving or picking | `audit:DateInput/accessibility` |## Decision logdiff --git a/packages/core/src/DateInput/DateInputTouch.test.tsx b/packages/core/src/DateInput/DateInputTouch.test.tsxindex 403f658852..57eab4b797 100644--- a/packages/core/src/DateInput/DateInputTouch.test.tsx+++ b/packages/core/src/DateInput/DateInputTouch.test.tsx@@ -1118,6 +1118,28 @@ describe('DateInput — calendar surface', () => {last.focus();fireEvent.keyDown(last, {key: 'ArrowRight'});expect(document.activeElement).toHaveAttribute('data-date', '2026-04-01');+ // The real April 1, not its dimmed spill copy at the foot of the March+ // pane (which is disabled and selects nothing).+ expect(pane('April 2026')).toContainElement(+ document.activeElement as HTMLElement,+ );+ expect(document.activeElement).not.toHaveAttribute('aria-disabled');+ });++ it('follows the reading direction under RTL: ArrowLeft moves to the next day', () => {+ renderAndOpen(+ <InternationalizationProvider locale="en-US" dir="rtl">+ <Controlled initial="2026-03-10" />+ </InternationalizationProvider>,+ );+ const day = within(pane('March 2026')).getByRole('button', {+ name: /March 10, 2026/,+ });+ day.focus();+ fireEvent.keyDown(day, {key: 'ArrowLeft'});+ expect(document.activeElement).toHaveAttribute('data-date', '2026-03-11');+ fireEvent.keyDown(document.activeElement!, {key: 'ArrowRight'});+ expect(document.activeElement).toHaveAttribute('data-date', '2026-03-10');});it('moves a week at a time with the vertical arrows', () => {diff --git a/packages/core/src/DateInput/MonthScroller.tsx b/packages/core/src/DateInput/MonthScroller.tsxindex 6201b5c766..63c8da6012 100644--- a/packages/core/src/DateInput/MonthScroller.tsx+++ b/packages/core/src/DateInput/MonthScroller.tsx@@ -637,12 +637,16 @@ export function MonthScroller({// Column within the displayed week, which is what Home/End move to —// not the day of the month.const column = (plainDateDayOfWeek(date) - weekStartsOn + 7) % 7;+ // The horizontal arrows follow the reading direction (APG grid): under+ // RTL the next day sits to the left.+ const forward = isRTL ? 'ArrowLeft' : 'ArrowRight';+ const backward = isRTL ? 'ArrowRight' : 'ArrowLeft';switch (event.key) {- case 'ArrowLeft':+ case backward:event.preventDefault();moveFocus(date, -1);break;- case 'ArrowRight':+ case forward:event.preventDefault();moveFocus(date, 1);break;@@ -666,7 +670,7 @@ export function MonthScroller({break;}},- [moveFocus, weekStartsOn],+ [isRTL, moveFocus, weekStartsOn],);// The focused day may have been in an unmounted pane a frame ago; focus it@@ -677,8 +681,11 @@ export function MonthScroller({if (!shouldRestoreFocusRef.current || focusedISO == null) {return;}+ // A date can be mounted twice: as a real day in its own pane and as a+ // dimmed, disabled spill copy at the edge of a neighbouring pane. Only+ // the real day may take focus, or Enter and Space would select nothing.const target = scrollerRef.current?.querySelector<HTMLElement>(- `[data-date="${focusedISO}"]`,+ `[data-date="${focusedISO}"]:not([data-outside])`,);if (target != null) {shouldRestoreFocusRef.current = false;@@ -835,6 +842,7 @@ function MonthPane({<buttontype="button"data-date={day.iso}+ data-outside={day.isOutside ? '' : undefined}tabIndex={day.iso === tabbableISO ? 0 : -1}aria-label={plainDateFormat(day.date,