Skip to content

fix(DateInput): keep cleared calendars empty - #6935

Open
korkt-kim wants to merge 1 commit into
facebook:mainfrom
korkt-kim:fix/6934-calendar-clear-selection
Open

korkt-kim wants to merge 1 commit into
facebook:mainfrom
korkt-kim:fix/6934-calendar-clear-selection

Conversation

@korkt-kim

@korkt-kim korkt-kim commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

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:

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 describes clear as resetting the selected value.
  • Calendar's existing consumer documentation 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 [Component Audit] DateTimeInput: keep cleared calendars empty #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

  • One remaining stale-selection defect is restored.
  • Already-merged sibling and Calendar changes are removed.
  • No new public API, visual representation, default, or interaction model is introduced.
  • 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.

@vercel

vercel Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 11, 2026 2:05pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 4, 2026
@astracat-bot

astracat-bot Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 11, 2026, 2:30 PM UTC

@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Oct 4, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the focused fix and the clear before/after tests — clearing a date input after a calendar pick no longer leaves the old date selected on reopen.

Approval needs one maintainer decision first: this introduces value={null} on Calendar as the controlled “no selection” value (with undefined staying uncontrolled), and there is currently no governing Calendar spec for that distinction. A maintainer needs to provide or identify the spec that settles Calendar controlled-empty in both single and range modes, including how it interacts with defaultValue and that onChange never emits null.

No other changes are requested: the select → clear → reopen behavior is covered for all three inputs, and existing uncontrolled use is preserved.

[Automated review]

@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

Modified Components

DateInput (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 3374 -
Complexity N/A Very High (362) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.9KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

26 of 458 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 754,077
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,188
Chat Full AI Chat probe light 155,733
Chat Full AI Chat probe dark 155,005
Chat Default neutral dark 33,205
Chat Default neutral light 32,876
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,229
Chat With Attachments probe dark 11,065
TableRowExpansion Detail Panel neutral dark 5,129
TableRowExpansion Detail Panel neutral light 4,050
SideNav Resizable in AppShell probe dark 3,208
SideNav Resizable in AppShell probe light 3,208
TableGroupedRows Default neutral light 2,133
TableGroupedRows Default neutral dark 2,116
Markdown Default probe dark 897
Markdown Default probe light 897

and 6 more.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@korkt-kim
korkt-kim force-pushed the fix/6934-calendar-clear-selection branch from e5d7caf to e27bf30 Compare October 11, 2026 13:58
@korkt-kim korkt-kim changed the title fix(Calendar): clear stale selection after clearing date inputs fix(DateInput): keep cleared calendars empty Oct 11, 2026
@korkt-kim

Copy link
Copy Markdown
Contributor Author

Thanks @cixzhang! After seeing yesterday's fixes in #7297 and #7298, I rebased this PR onto the latest main and removed the overlapping Calendar, DateRangeInput, and DateTimeInput changes.

This now covers only the remaining DateInput controlled-empty boundary and the locale-consistency example, with regression tests. The DateInput fix follows the same ?? null pattern as #7298, and includes a select → clear → reopen Storybook regression.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for narrowing this to the remaining DateInput piece: keeping the popover Calendar controlled while the field is empty means a cleared DateInput no longer reopens with the old date selected, matching the pattern DateTimeInput already uses on main. The new select → clear → reopen regression test covers exactly that outcome, so this automated review requests no changes; the pull request still needs the usual maintainer review before merging.

[Automated review]

This branch was successfully deployed

1 active deployment
Preview — e27bf30f Deployed Oct 11, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Date inputs retain Calendar selection after clearing

1 participant