Repository navigation
fix(DateInput): a focused sheet month arrow that hides at the range end hands focus on first - #10231
Conversation
…nd hands focus on first In the touch sheet, a month arrow at the first or last month of the range is hidden, and a hidden element loses focus, so a keyboard user who stepped to the end landed on the page. Before the step, focus now moves to the other month arrow, or to the month-and-year button when both arrows hide. The DateInput record names that destination (FR22), as AST-085 FR4 requires.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec 79151ec |
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| DateInput · Storybook | 178.8 kB (+284 B) · 16.6 kB CSS (0) | 5,636 (+50) | ✓ · ✓ · ✓ |
| PowerSearch | 278.3 kB (+188 B) · 23.3 kB CSS (0) | — | — · — · — |
Package size: @astryxdesign/core 6.85 MB packed (+1.2 kB); no new dependencies.
API changes: none in this pull request
Committed API report behind this build: cli 19 rows, core 24 rows; run pnpm api:report.
Touched components checked; add ci:run-visual or ci:run-rtl to run the full suites.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Changes requested: the focus handoff works in ranges of three or more months, but in a range that spans two calendar months focus still falls to the page.
- In a two-month range (for example the
WithMinMaxstory, Jan 15 – Feb 15, shown as a bottom sheet),stepMonthFromArrowfocuses the other arrow while it is still hidden and disabled, so focus falls to the page body when the pressed arrow hides; move focus once the step has committed (note focus,flushSyncthe step, then move it) and add a two-month case to the test. - The handler's
activeElementcheck and barefocus()re-implement whatnoteFocusWithinandmoveFocusLeftBehindinutils/focusReturn.tsalready do for content a change hides, so call that pair instead of keeping a local copy. - The changeset and title promise that focus is kept whenever an arrow reaches the end of the range, and the test plan points to a real-browser comment that is not on the pull request, so make both match what the fix and its tests show.
FR22 already has an engineering owner's approval for this head; the push that fixes these needs a fresh /approve-spec for its new head.
[Automated review]
…shown arrow can take it In a two-month range the arrows trade places on one step: the other arrow is hidden until the step renders, and a hidden element cannot take focus. The step now renders first (flushSync), then focus moves. A Chromium spec proves both directions on the WithMinMax story; jsdom does not move focus off a hidden element.
|
/approve-spec 6a0afc5 |
There was a problem hiding this comment.
Changes requested: focus now stays in DateInput's sheet when a month arrow hides at either end of the range, and two fixes remain.
stepMonthFromArrowre-implements the shared focus path with its ownactiveElement === arrowcheck and a barefocus()(TouchDateField.tsxlines 918 and 929); callnoteFocusWithin(arrow)before theflushSyncstep andmoveFocusLeftBehind(note, destination, arrow)after it, as Collapsible, LayoutPanel and TreeList do.- Miss: the changeset has no contributor line, so
pnpm check:changesetsfails inside the requiredlintcheck once CI runs on this pull request; add@cixzhangon its own line after the text.
In Chromium, focus on main falls to the page body at both range ends and lands on the other arrow here. Optional: trim the comment above the handler to its two reasons, add the Chromium spec to FR22's verification row and verified_by, and change "before the step" in the description, since focus moves after the step renders.
[Automated review]
…focusReturn path noteFocusWithin notes focus on the arrow before the step, and moveFocusLeftBehind moves it to the destination after, only when the hidden arrow would lose it. The ring follows the last input, so the sheet keeps modality tracking active.
|
/approve-spec 90232c1 |
There was a problem hiding this comment.
Changes requested: focus now stays in DateInput's sheet when a month-arrow press reaches either end of the range, and the handler goes through the shared focus-return path, but three fixes remain.
- Miss: FR22 in the DateInput record says focus moves to the other arrow whenever a focused month arrow hides at the range end, but only an arrow press does that, so with focus on an arrow a swipe to the first or last month still drops focus to the page body; run the same handoff from
handleVisibleMonthChange, or limit FR22 to arrow presses and list the swipe case as a known gap, then record a new/approve-spec. - Miss: the changeset has no contributor line, so
pnpm check:changesetsfails inside the requiredlintcheck once CI runs; add@cixzhangon its own line after the text. - The
useInteractionModalityTrackingFor(sheetBodyRef)call inTouchDateField.tsx(line 690) adds an Effect that re-runs after every commit of the field, for tracking that the sheet's ownBottomSheetalready does on its dialog; remove the call and its import, or, if the field must own its tracking, calluseInteractionModalityTracking()and merge its ref onto the sheet body.
In Chromium the base leaves focus on the page body after Enter or a tap on the end arrow, and this head moves it to the other arrow, with a ring after Enter and none after a tap. Non-blocking: the handler's comment can drop "An arrow steps a month." and shorten its two longest sentences.
[Automated review]
…it); the changeset credits its author
|
/approve-spec 01aa12d |
There was a problem hiding this comment.
Changes requested: a month-arrow press at either end of the range now keeps focus in DateInput's touch sheet, in both directions and in a two-month range. One item remains:
- Miss: FR22 (
docs/specs/components/DateInput/DateInput.spec.mdline 188) and the title say focus moves to the other arrow whenever a focused month arrow hides at the range end, but after a tap on Previous month and a swipe to the first month focus still falls to the page body, so either run the same handoff whenhandleVisibleMonthChangereports an end month, or narrow FR22, the title and the changeset to arrow presses and record a new/approve-spec.
Non-blocking: the comment above stepMonthFromArrow can keep only its two reasons (see the existing inline note).
[Automated review]
…w as a press does A tap on Previous month, then a swipe to the first month, hid the focused arrow and dropped focus to the page. The move to a new month, by an arrow or a swipe, now runs the same handoff: focus moves to the other arrow, or to the month-and-year button when both hide. The comment keeps only its reasons, the changeset names both inputs, and FR22's verification row names the new swipe case.
|
/approve-spec fc5a13d |
There was a problem hiding this comment.
Approved: CI passed on this head.
A focused month arrow in DateInput's touch sheet now hands focus to the other arrow when an arrow press or a swipe reaches the end of the range, both new tests fail without the change, and the new Chromium spec passes in CI. Two non-blocking suggestions:
- FR22 reads as if it also covers a caller changing
minormaxwhile an arrow holds focus, but that path still drops focus to the page, as it did before; consider listing it under the record's known verification gaps, or scoping FR22 to a press or a swipe. - FR22's verification row names only the jsdom tests; adding
DateInputSheetMonthArrowFocus.a11y.chromium.spec.tsthere (and toverified_by) records the real-browser check thatspec:AST-085FR4 asks for.
[Automated review]
| | FR19 | The bottom-sheet calendar's weekday row MUST show the weekday names `component:Calendar` DD1 sets for the provider locale, in the order of the panes' day columns (`weekStartsOn`), so both pickers label a locale's columns alike. | | ||
| | FR20 | The pointer field reads and writes typed dates in the resolved calendar (`spec:AST-111` FR2), and its Calendar shows that calendar. It reads the dates `Intl.DateTimeFormat` writes for the locale and calendar, in any Unicode decimal digits and with month and era names of the locale and English; in the Gregorian calendar, text that matches none of these forms, or that these forms read as a date the calendar does not have, still commits on Enter or blur when `parseDateInput` reads it, so `13/5/2026` in `en-US` commits as 13 May 2026 (`spec:AST-111` FR9). A typed year is a year of the calendar (`spec:AST-111` FR10). It rejects a date the calendar does not have and never adjusts it; a typed date outside `min`, `max`, or `dateConstraints` shows and announces an out-of-range error that writes the bounds in the calendar, and Enter or blur keeps both kinds of rejected text so the person can correct it, while unreadable text reverts (`spec:AST-111` FR11). While a person types, `onChange` fires only for complete input, at most once for each distinct value in one typing session, and a one-digit day stays open until another digit, Enter, or blur, so a day the month lacks is never reported as another date; a two-digit year and input without a year commit on Enter or blur, in every calendar system, and a year of one or three digits is not a date: like other text the field cannot finish, Enter or blur keeps it and shows the unreadable message as the field status (`spec:AST-111` FR12, AR3). Each rejection is announced once: a shown status announces itself, and the field's alert carries only a rejection that no status shows. `date`, `date_long`, and `date_weekday` write the committed text in the calendar and read back as the same date; `system_date` stays Gregorian ISO and the field reads ISO input with it (`spec:AST-111` FR13). Text from a custom `format` function that the field cannot read back cannot be re-committed after an edit (`spec:AST-111` FR14). Values stay Gregorian ISO dates (`spec:AST-111` FR3). | `spec:AST-111` FR3, FR9–FR14; current source; parser, round-trip, and calendar typed-entry tests | | ||
| | FR21 | With a calendar other than `gregory` or `iso8601`, every presentation that would show the native control — `adaptive-native`, the default, deprecated `touch` and `always`, and an explicit `native` — shows the popover on a fine pointer and the bottom sheet on a coarse pointer, because the native control is Gregorian (`spec:AST-111` FR15). An explicit `native` also warns once in development. The bottom sheet shows months of the calendar: each scroller pane lays out one calendar month with calendar labels and day names and the locale's digits, as `component:Calendar` shows it, and every pane keeps the six-row height, including the five- or six-day thirteenth month of the Coptic and Ethiopic calendars. The month wheel lists the months of the selected calendar year, leap months by name; a year change keeps the month when the new year has it and otherwise moves to its common counterpart (Adar I becomes Adar); year labels carry the era where the calendar has one, such as `令和8`, and a year whose first and last days fall in different eras keeps one row, labeled with the era year of the date the wheels show: that year, the selected month, and the day the picker keeps, clamped to the month, else the month's first day. So 2019 reads `平成31` with January selected and `令和元` with July, and the row's text and accessible name change as the month wheel turns, while its size stays the same. The month and year heading takes its era from the same date when the shown month spans an era change, so January 1989 reads `昭和64年1月` for a kept day of 3; every other heading names the era of the month's middle day. A pane's grid name always takes the era of its month's middle day, so that pane reads `平成元年1月`. The closed sheet field writes the committed text in the calendar (`spec:AST-111` FR16). Values stay Gregorian ISO dates (`spec:AST-111` FR3). | `spec:AST-111` FR3, FR15, FR16; current source; calendar presentation, touch calendar, and no-`Temporal` tests | | ||
| | FR22 | In the touch sheet, a month arrow at the range end is hidden; if it held focus, focus moves first to the other month arrow, or to the month-and-year button when both are hidden (`spec:AST-085/FR4`). | `spec:AST-085/FR4`; current source and sheet arrow tests | |
There was a problem hiding this comment.
Non-blocking: as written FR22 also covers a caller that narrows min or max to the shown month while an arrow holds focus, but no handler runs then, so that arrow hides and focus still falls to the page (as on main). Listing it under Known verification gaps, for example "A min or max change that hides a focused month arrow drops focus to the page, against spec:AST-085 FR4", or scoping FR22 to a press or a swipe, keeps the record accurate.
| | FR19 | `DateInputTouch.test.tsx` "labels the columns with three-letter weekday names", "labels the columns in %s with the same names as the Calendar header" for `fr-FR`, `pt-PT`, `pl-PL`, and `id-ID`, "rotates the weekday header with weekStartsOn" | English; a locale within Calendar DD1's four-character limit; locales above it; a locale with no shipped weekday data; `weekStartsOn` rotation | A weekday row that differs from the Calendar header names for the same locale, or that does not rotate with `weekStartsOn`, fails. | — | | ||
| | FR20, AR3, AR9 | `calendarDateParser.test.ts` reading, year, rejection-kind, completeness, committed-text, and calendar-name cases; `calendarDateParser.roundtrip.test.ts` committed text and format hint of every calendar in its native locale, English, and Swedish, sampled from 1900 through 2100; `DateInput.calendar.test.tsx` ("reports one Persian date typed in Persian digits, only when complete", "reads a plain Adar in a Hebrew leap year as Adar II", "reads Japanese era dates and rejects a year outside its era", "rejects a date the calendar does not have and keeps it on blur", "shows an out-of-range error with the bounds in the calendar", "announces a different message for each kind of rejection", "fires once for a day-first date typed one key at a time", "commits Gregorian text that only parseDateInput reads, on blur only", "commits a day-first date that does not exist month-first, on blur only", "commits a month-first date that does not exist day-first, on blur", "never falls back to a month-first reading in a day-first locale", "keeps a one-digit year on %s and announces it as invalid", "reports no date while %s %s text grows to a day the month lacks", "reports a retyped date again after the caller keeps its value", "still rejects a Gregorian date that does not exist in either order", "never reads a date that does not exist in another calendar with parseDateInput", "shows a format hint in the empty focused field", "shows a caller placeholder instead of the format hint", "uses max when max is before today", "uses min when min is after today", "uses the nearest weekday when today is a disabled Saturday", "names the calendar in the description", "names no calendar when the field uses the provider calendar", "names the Gregorian calendar inside a Persian provider", "names no calendar for an iso8601 field in a Gregorian provider", "names the Persian calendar without a provider calendar"); real Chromium and Firefox typing with native `Temporal`, a polyfill, and no `Temporal` | Persian digits, Hebrew leap year, Japanese era change, Buddhist bounds, partial input, Gregorian day-first typing, a one-digit Gregorian year, no `Temporal` | A typed date reported before it is complete, an adjusted date, a failed round trip, Gregorian text that FR20 says commits failing to commit on blur, a one-digit year that commits or reverts silently, a rejection announced twice, a shared rejection message, a missing hint, a hint that replaces a caller placeholder, a hint example the field rejects, a calendar description that is missing or that repeats the provider's calendar, or a non-ISO value fails. Evidence gap: no WebKit run; no server render and hydrate test. | `audit:DateInput/behavior` | | ||
| | FR21 | `DateInput.calendarPresentation.test.tsx` (every presentation and deprecated `nativePicker` value in Gregorian and Persian on fine and coarse pointers; "warns once when an explicit native cannot show the calendar"); `DateInputTouch.calendar.test.tsx` ("lays out a Persian month with its days, labels and locale digits", "shows Adar I and Adar II as separate months in a Hebrew leap year", "keeps six rows for the Ethiopic thirteenth month", "lists 13 months in a Hebrew leap year and 12 in a common year", "labels Japanese years with their era", and the month-model round trips); `calendarSystem.test.ts` `formatCalendarYearLabel` and `calendarYearSpansEras` cases (2019 in January and May, 1989 on January 3 and 22, 1926, 1912, and 2020); `DateInputTouch.calendar.test.tsx` "names the era of the shown month for a year with an era change" and the split-month heading cases (January 3, 1989; December 26, 1926); `calendarSystem.test.ts` `formatCalendarMonthLabel` kept-day cases; `DateInput.noTemporal.test.tsx`; real Chromium, Firefox, and WebKit bottom sheets and popovers with native `Temporal`, a polyfill, and no `Temporal` | Persian, Hebrew leap and common years, Ethiopic thirteenth month, Japanese eras, no `Temporal` | A native date control for a non-Gregorian calendar, a wheel with 12 months for a 13-month year, a pane of another height, a lost leap month, a missing era, a year with an era change labeled with an era other than that of the shown date, or a non-ISO value fails | `audit:DateInput/behavior` | | ||
| | FR22 | `DateInputTouch.test.tsx` "moves focus to the other arrow when the focused arrow reaches the end of the range and hides" and "moves focus to the other arrow when a swipe reaches the end of the range while an arrow holds focus" | Sheet month arrows at the first and last month of a range | Focus left on a hidden arrow, or dropped to the document body, fails. | `audit:DateInput/behavior` | |
There was a problem hiding this comment.
Non-blocking: jsdom cannot show a hidden element losing focus, so the real-browser check spec:AST-085 FR4 asks for is the new DateInputSheetMonthArrowFocus.a11y.chromium.spec.ts. Naming it here, and in verified_by, records that evidence.
Main gained meta#10231, which adds DateInput FR22 for the touch sheet's month arrows. This pull request's month/year wheel requirement moves from FR22 to FR23, with its verification row, the Bottom-sheet calendar row, the scope line and DateTimeInput FR14's two citations. Only the numbers change; this pull request's own changes are otherwise unchanged.
Under a primary finger the calendar is now MonthPager, which a scroll event does not move, so meta#10231's swipe hand-off test never reached the range end. It runs as the other native-scroller tests here do: on a touchscreen laptop with the sheet pinned. MonthPager reports its settled month to the same callback. meta#10386 has an armed hold name the motion it judges. The pager's four holds judge the track's translate, which a step and a settle move.
This pull request now sits on meta#8200's merge with main, so the stack is tested and merged together. Main gained meta#10231. It adds DateInput FR22 for the touch sheet's month arrows, so this pull request's chevron and toggle requirements move from FR23 and FR24 to FR24 and FR25, after the wheels' FR23: their verification rows, the Bottom-sheet calendar row and DateTimeInput FR15's citations follow. Only the numbers change. meta#10231 also gives the month arrows a focus hand-off at the range end. The merge keeps it inside this pull request's memoized arrows (their refs and stepMonthFromArrow), and a swipe hands focus on through the month grid's callback, which still reads the wheels' state through a ref, so the toggle leaves it unchanged. The title button takes main's ref for that hand-off and this pull request's chevron ref through useMergedRefs.
meta#10231 moves focus off a month arrow that hides at the range end. Two tests check that the hand-off still runs through what the toggle keeps: - the arrows, which the toggle does not re-render: a press after the toggle still moves focus to the other arrow; - the month grid's callback, which the toggle leaves unchanged, so the memoized pager does not re-render: a month the pager settles on after the toggle still moves focus the same way. Each test fails if the toggle re-renders what it keeps, or if the hand-off is lost. meta#10386 has an armed hold name the motion it judges. The toggle storyboard's hold judges the wheels' opacity, which the fade moves.
…ove the date like UIDatePicker's (#8209) * fix(DateInput, DateTimeInput): under a finger the month/year wheels move the date like UIDatePicker's Under a finger, turning the month or year wheel behind the sheet calendar's title moves a chosen date to the wheels' month and keeps its day: October 15 becomes May 15, and a day the month lacks becomes its last day (January 31 becomes February 28), inside min and max, by the months of the calendar the sheet shows; DateTimeInput keeps the time. A date dateConstraints refuses is not chosen, and with no date chosen the wheels move only the calendar. With a mouse the wheels move the calendar only, as today. The month wheel does not loop. DateInput FR22 records the rule under a coarse primary pointer, and DateTimeInput FR14 does the same and keeps the time. Each has a verification row. * test(DateInput): the month/year wheels' proof waits on the sheet's own end, not on still frames before a deadline `openWheels` waited for the sheet, and then for the wheels, with the harness's `waitForRest`: three still frames within 5 s. On a loaded runner the page can present no frame for 6 s right after the sheet opens, so the wait ran out with nothing moving ("still moving", while the page held no animation). The proof now checks the sheet's open transform, and then the wheels' full opacity, once a frame with no deadline of its own, and waits on each animation's `finished` promise. A starved runner only makes it later. * refactor(DateInput, DateTimeInput): the wheels' comments keep the reason The comments above both sheets' handleWheelChange keep only the reason: UIDatePicker moves a chosen date with the wheels. The day and bound clamps read from dateInMonth itself, which moves the date by the calendar's own months through calendarShiftMonths. * Merge main into the month/year wheels Main gained #10285, which adds a `getOnlyButton` import beside the testing-library import this pull request widens in DateTimeInputTouch.test.tsx. The merge keeps both imports; this pull request's own changes are unchanged. * Merge main into the month/year wheels Main gained #10231, which adds DateInput FR22 for the touch sheet's month arrows. This pull request's month/year wheel requirement moves from FR22 to FR23, with its verification row, the Bottom-sheet calendar row, the scope line and DateTimeInput FR14's two citations. Only the numbers change; this pull request's own changes are otherwise unchanged.
User impact
A keyboard or screen-reader user in DateInput's touch sheet who steps the month with the header arrows lost focus at the end of the range: the arrow they were on hides there, and focus fell to the page, so they had to find their way back into the sheet. Now, before the step, focus moves to the other month arrow, or to the month-and-year button when both arrows hide, so the next key press still acts in the sheet.
Problem and solution fit
visibility: hidden(a deliberate visual choice for the sheet). A focused element that becomes hidden loses focus.spec:AST-085FR4 says that when a component removes a focused control, its record names the destination. The DateInput record now does (FR22): the other month arrow, or the month-and-year button when both arrows are hidden.noteFocusWithin), renders the step (flushSync), and then moves focus to the destination through the shared path (moveFocusLeftBehind), only if the hidden arrow would lose it; the ring follows the last input, using the modality tracking the sheet already runs. The step renders first because in a two-month range the arrows trade places on one step, and the other arrow cannot take focus while it is still hidden. There is no Effect and no new prop. The hidden end arrow is unchanged.aria-disabled.Test plan
DateInputTouch.test.tsx"moves focus to the other arrow when the focused arrow reaches the end of the range and hides": fails onmain's TouchDateField (focus stays on the hidden arrow) and passes here.New
DateInput/__tests__/DateInputSheetMonthArrowFocus.a11y.chromium.spec.ts(WithMinMax story, bottom-sheet presentation, phone profile; Enter on the arrow that steps to the end of the range, in both directions). Real Chromium: fails 2 of 2 on amainStorybook (focus on<body>), passes 6 of 6 (--repeat-each=3) on this head's Vercel preview Storybook.DateInput suite: 652 passed. Lint and
tscare clean, andpnpm check:knowledgeis aligned.The last head only removes a redundant modality-tracking call and adds the changeset's credit line; its unit, lint and type checks are CI-only. The real-Chrome result above is from the previous head (90232c1), whose focus path is unchanged.
Writing rubric results
R1 narration: none; FR22 is one present-tense statement of the sheet's behavior.
R2 research: none in the record.
R3 evidence: FR22's basis is
spec:AST-085/FR4, current source and the sheet arrow test; no pull request or commit is cited.R4 rejected alternatives: none in the record.
R5 change references: none.
R6 open questions: none.
Follow-up at fc5a13d
moveMonthhelper runs the handoff for both inputs.tscexited 0, and knowledge and changesets checks pass.