Repository navigation
[Component Audit] DateRangeInput: keep range state truthful - #7297
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report
|
There was a problem hiding this comment.
Thanks — this keeps DateRangeInput's range state truthful in three places that had drifted apart. Required state is now announced through a valid description on the button trigger (with the obsolete axe baseline exemption removed), the trigger's accessible name and the calendar follow the optimistic value while a save is pending, and clearing the field no longer brings the old selection back when the calendar reopens.
Calendar's newly documented value={null} controlled-empty state is additive and matches what the runtime already did, so existing calls are unaffected. I verified the focused Calendar/DateRangeInput and PowerSearch tests, the core typecheck, and before/after rendered axe results on the Required story; no blocking findings from me.
[Automated review]
## User impact After selecting a date through DateInput's calendar, clearing the field and reopening the calendar still shows the previous date as selected. This fix keeps the empty field and Calendar selection consistent. Fixes #6934 ## Scope after rebase Rebased onto `main` at `2514d86d02ffa32b1c17b32523e1149eb86334fe` and removed the portions already covered by: - #7297: Calendar's controlled-empty support and DateRangeInput's clear behavior. - #7298: DateTimeInput's clear behavior. The remaining change is the DateInput composition and the original locale-consistency example, with regression evidence and a scoped patch changeset. Calendar, DateRangeInput, and DateTimeInput have no diff against the rebase target. ## Problem and solution fit Calendar treats `undefined` as uncontrolled. Selecting a date updates its internal selection; passing `undefined` after DateInput clears lets that old selection become visible again. DateInput now passes `optimisticValue ?? null` to Calendar, following the same controlled-empty boundary used by DateTimeInput in #7298. DateInput's public value type, `onChange(undefined)` clear callback, optimistic change pipeline, and picker presentation stay unchanged. ## Expected behavior and authority - [DateInput's consumer documentation](https://github.com/facebook/astryx/blob/2514d86d02ffa32b1c17b32523e1149eb86334fe/packages/core/src/DateInput/DateInput.doc.mjs) describes clear as resetting the selected value. - [Calendar's existing consumer documentation](https://github.com/facebook/astryx/blob/2514d86d02ffa32b1c17b32523e1149eb86334fe/packages/core/src/Calendar/Calendar.doc.mjs) defines `null` as controlled-empty and omitted/`undefined` values as uncontrolled. - Once the parent accepts clear, the reopened calendar should have no selected gridcells. Visible month, today's marker, and keyboard focus remain separate from selection. - No public API or type widening remains in this PR. ## Smallest restoration - Normalize DateInput's empty value to `null` only at its Calendar boundary. - Keep the locale-consistency example's Calendar controlled when its shared date is empty. - Add a select → clear → reopen unit regression and a `ClearedCalendarSelection` Storybook play function, following #7298's evidence pattern. - Narrow the changeset to DateInput; retain contributor attribution. ## Evidence - **Before:** without the DateInput boundary normalization, the new regression fails with one selected gridcell instead of zero. - **After:** the test verifies that a calendar selection exists before clear, that clear empties the input, and that reopening leaves zero selected gridcells. - **Browser endpoint:** `Core/DateInput/ClearedCalendarSelection` selects April 15, clears, reopens, and asserts an empty field with no selected day. Its final open-calendar frame is tagged `visual-baseline`. - **Representative unchanged paths:** related suites cover ordinary selection, constraints, callbacks, native and touch presentations, and the already-merged Calendar/DateRangeInput/DateTimeInput clear behavior. - No CSS, geometry, token, role, or DOM-anatomy change. Only the stale selected-day state is removed. This is not a new cross-browser or assistive-technology audit. ## Scope - [x] One remaining stale-selection defect is restored. - [x] Already-merged sibling and Calendar changes are removed. - [x] No new public API, visual representation, default, or interaction model is introduced. - [x] Public text and artifacts contain no internal operational context. ## Testing - `pnpm build` — passed. - `pnpm -F @astryxdesign/core typecheck` and `pnpm -F @astryxdesign/storybook typecheck` — passed. - Commit hooks (staged-file ESLint/Prettier and `pnpm check:repo`) — passed; the user-reviewed patch is unchanged by the hooks. - `pnpm lint:strict --ignore-pattern 'assets/**'` — passed. The plain command picked up a local, ignored generated bundle under `assets/`; that directory contains no tracked files. No repository lint rules or configuration were changed. - `pnpm test --maxWorkers=4` — **22,668 passed, 2 failed, 2 expected failures, 40 skipped**. All DateInput and related date-component suites pass. The only failures are the two taxonomy assertions in `apps/storybook/.storybook/story-tree.test.ts`, which read a pre-existing local Storybook index. Both failures were independently reproduced with the exact `main` version of that test and the same index; the test itself is unchanged. They are not reported as passing and are outside this fix. - Headless Chromium, `Core/DateInput/ClearedCalendarSelection` — passed: empty field, reopened calendar, zero selected gridcells, no page errors. - `git diff --check` — passed.
User impact
People using DateRangeInput with assistive technology can now hear required state without invalid ARIA, hear the same pending range that is visible while a change saves, and reopen a cleared calendar without the previous range appearing selected.
Problem and solution fit
Three state seams drifted apart:
aria-required, which is not valid on that role;valuewhile the visible trigger read the optimistic value;undefinedto Calendar, allowing Calendar to fall back to its old internal range.The fix keeps the existing button contract. Required state uses the established localized hidden-description pattern, the trigger name and Calendar both consume the optimistic controlled value, and Calendar documents
nullas its explicit controlled-empty value.Expected behavior and authority
DateRangeInputFR1 requires one controlled range without a competing selected range.family:input-fieldsFR6 requires optimistic value feedback duringchangeAction.aria-describedbytarget rather than unsupportedaria-required.Smallest restoration
Calendar.valueonly widens its type to admit thenullcontrolled-empty state already handled at runtime.Credit: this repair incorporates the problem reports and implementation evidence from #4689 and #6935.
Audit score
Rubric 1.16.6:
Changed sections: accessibility 2.5→4.5, behavior 3→5, testing 4→5. Other section scores are unchanged.
Evidence
aria-allowed-attrbaseline row.94f81034f22306ca4329c111c6c2df0224ef1cfe.Scope
Testing
pnpm lint:strictpnpm build