Repository navigation
[Component Audit] DateTimeInput: keep cleared calendars empty - #7298
Conversation
|
AI review status for this pull request.
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR Analysis Report
|
There was a problem hiding this comment.
Thanks for the focused fix and the clear audit trail. Keeping the calendar explicitly controlled-empty after a clear resolves the contradictory state where the field was empty but the previous day still appeared selected, and it does so without changing the public API or the clear callback contract.
I verified the select → clear → reopen sequence leaves no selected day, alongside the related DateTimeInput test suites and knowledge checks. The new component record stays a draft observation for owner review and does not change any governing requirement. No changes are requested.
[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 who select a date from DateTimeInput’s calendar, clear the field, and reopen the calendar no longer see the previous date still highlighted. The visible empty field and Calendar selection now describe the same state.
Audit result
core/DateTimeInput0d8dadb0d815cbd3091a5e93a8e98095651b840b5e000a582a7b33e0643c974df8ec3147015b41ccFindings fixed
undefinedto Calendar after clear, which released Calendar into uncontrolled mode and revived its prior internal selection. The component now passes explicit controlled-emptynull, using Calendar’s current controlled-empty contract without changing DateTimeInput’s public API.The clear-state diagnosis and original regression shape came from @korkt-kim’s focused fix. The changeset preserves that attribution alongside
@cixzhang.Authority and compatibility
spec:AST-043remains the current owner of picker presentation, precedence, compatibility mapping, and native fallback behavior; none changes here.family:input-fieldscontinues to own controlled optimistic changes, busy state, field geometry, status, and disabled reasons.DateTimeInput.spec.mdis a draft observational record. It adds no current product authority and introduces no new prop, default, role, interaction, or migration.onChange(undefined); only its internal Calendar boundary remains explicitly controlled-empty.Evidence
shows no selected calendar days after clearingreceived one selected gridcell on the base source.ClearedCalendarSelectionselects March 20, clears, reopens, asserts zero selected gridcells, and leaves the reopened empty Calendar as an opted-in stable visual frame.5e000a582a7b33e0643c974df8ec3147015b41cc.Needs Review
No owner decision blocks this audit. Three pre-existing code-health FIX groups remain recorded rather than expanded into this behavior repair: Effect-based touch-draft synchronization, Effect-based prop-driven layer closure, and Effect-based trigger registration. They are separately refactorable and do not invalidate the restored clear path.
Writing rubric results
Testing
pnpm exec vitest run packages/core/src/DateTimeInput/DateTimeInput.test.tsx packages/core/src/DateTimeInput/DateTimeInputTouch.test.tsx packages/core/src/DateTimeInput/NativePickerSegments.test.tsx packages/core/src/DateTimeInput/Presentation.test.tsx --maxWorkers=4— 212 passed.pnpm -F @astryxdesign/core typecheck— passed.pnpm -F @astryxdesign/storybook typecheck— passed after package build.pnpm build— passed.pnpm storybook:build— passed.pnpm lint:strict— passed with 0 errors; repository-existing warnings only.pnpm check:knowledgeand commit hooks — passed.