Skip to content

fix(date inputs): clear rejected text on controlled clear - #12096

Open
bezabyte wants to merge 3 commits into
meta:mainfrom
bezabyte:codex/issue-12079-clear-rejected-date-text
Open

bezabyte wants to merge 3 commits into
meta:mainfrom
bezabyte:codex/issue-12079-clear-rejected-date-text

Conversation

@bezabyte

Copy link
Copy Markdown

What changed

DateInput and DateTimeInput now clear rejected typed date text when their controlled value is explicitly changed to undefined.

The existing value-replacement behavior is preserved: a value restored in the same Enter or blur update that keeps rejected text still leaves that text available for correction.

Why

When rejected text had never reported a date, lastFiredDate was already undefined. A controlled clear to undefined therefore looked like the date typing had just reported, so the field kept the rejected text and its error state instead of becoming empty.

Before / after

Before:

<input value="tomorrowish" aria-invalid="true" />
<!-- controlled value changes to undefined; rejected text remains -->

After:

<input value="" />
<!-- aria-invalid and the rejection message are removed -->

This is a controlled-state and accessibility-state fix, not a visual styling change. A screenshot would not honestly prove the behavior, so the regression asserts the actual input value and ARIA state.

Verification

  • Full DateInput.test.tsx: 200 passed.
  • New DateInput clear regression: passed.
  • New DateTimeInput clear regression: passed.
  • Existing caller-restore/retyped-date regression: passed.
  • Core typecheck: passed.
  • pnpm check:repo: passed.
  • Targeted ESLint and git diff --check: passed.
  • Pre-commit checks: passed.

The full DateTimeInput suite also reports one unrelated existing Korean hour-cycle assertion failure; the focused DateTimeInput regression for this change passes.

Closes #12079

@vercel

vercel Bot commented Nov 16, 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 Nov 20, 2026 7:03pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 16, 2026
@bezabyte

Copy link
Copy Markdown
Author

Implementation is in d3bbc173610f2c5d52d3568123108537075e0e24.

A controlled value={undefined} now clears rejected typed date text and removes its invalid/error state in both DateInput and DateTimeInput. The existing caller-restore path remains unchanged.

Verification:

  • Full DateInput suite: 200 passed
  • DateInput and DateTimeInput clear regressions: passed
  • Existing caller-restore regression: passed
  • Core typecheck, pnpm check:repo, targeted ESLint, git diff --check, and pre-commit checks: passed

The CLI printed a GitHub permission warning while requesting reviewers, but verification shows cixzhang, imdreamrunner, and josephfarina attached to the PR.

@astracat-bot

astracat-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 20, 2026, 7:22 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 Nov 16, 2026

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved pending CI: CI has not run on this head yet. A maintainer adds the ci:run label so CI runs; the label takes effect on the next push, or a close and reopen.

A controlled value cleared to undefined now empties kept rejected text, its invalid state and its message in DateInput and in DateTimeInput's date segment, as the rejected-entry spec requires for any later new value, while a value passed at the Enter or blur that keeps the text still keeps it. Both new regression tests fail without the fix and pass with it.

  • Optional: the new comment in useTypedDate.ts (lines 508-511) can keep only its reason: typing never reports undefined, so a clear to undefined always comes from outside.
Claims and files checked

Review mode: same-head; reason: none

  • changed rules (0): none
  • Claim: clearing the controlled value to undefined empties rejected typed date text in both components — verified (the two new tests fail before the fix and pass after; a browser capture of the date-time field's clear button shows the same).
  • Claim: a value restored at the Enter or blur that keeps rejected text still keeps it — verified (the existing restore tests pass; the shared replacement check is unchanged).
  • Claim: the cause is that "no date reported" and a cleared value looked the same — verified (the hook's value-change branch before the fix).
  • Claim: after the clear the input is empty with no invalid state or message — verified (the tests assert the value, the invalid attribute and the status text).
  • Claim: no visual styling change — verified (no style changes).
  • Claim: the full DateInput suite passes with 200 tests — verified (200 of 200).
  • Claim: the new DateInput and DateTimeInput regressions and the existing caller-restore and retyped-date regressions pass — verified.
  • Claim: core typecheck passes — verified.
  • Claim: repository checks pass — verified for 24 of 27 checks; the three that read git history could not run in this review.
  • Claim: targeted ESLint and the whitespace check pass — verified.
  • Claim: pre-commit checks pass — not checked here.
  • Claim: one existing Korean hour-cycle failure in the full DateTimeInput suite — not reproduced (215 of 215 passed).
  • Claim: closes the linked issue — verified (its reproduction is the new test case).
  • Changeset: a core patch noting that both components clear rejected text on a controlled clear — verified (matches the change; the changeset check passes).
  • File .changeset/date-input-clear-rejected-text.md — clear.
  • File packages/core/src/DateInput/useTypedDate.ts — clear (one optional comment suggestion).
  • File packages/core/src/DateInput/DateInput.test.tsx — clear.
  • File packages/core/src/DateTimeInput/DateTimeInput.test.tsx — clear.

Automated review (maintainer link)

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec d3bbc17

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 16, 2026
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec d3bbc17

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec ec30a65

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved pending CI: CI has not run on this head yet. The ci:run label is applied, and the CI, CI review pass, Lint and CLI Smoke Test runs on this head are waiting for a maintainer to approve them.

A controlled value changed to undefined now empties kept rejected text, its invalid state and its message in DateInput and in DateTimeInput's date segment, as the rejected-entry spec requires for any later new value, while a value passed at the Enter or blur that keeps the text still keeps it. Both new regression tests fail without the fix and pass with it.

  • Optional: the new comment in useTypedDate.ts (lines 508-511) can keep only its reason: typing never reports undefined while text is held, so a clear to undefined always comes from outside.
Claims and files checked

Review mode: full; reason: other:cited records changed on main

  • Claim: clearing the controlled value to undefined empties rejected typed date text in both components — verified (the two new tests fail before the fix and pass after; a browser capture of the date-time field's clear button shows the same).
  • Claim: a value restored at the Enter or blur that keeps rejected text still keeps it — verified (the existing restore tests pass, and a probe that clears to undefined at that blur keeps the text).
  • Claim: the cause is that "no date reported" and a cleared value looked the same — verified (the hook's value-change branch before the fix).
  • Claim: after the clear the input is empty with no invalid state or message — verified (the tests assert the value, the invalid attribute and the status text).
  • Claim: no visual styling change — verified (no style changes).
  • Claim: the full DateInput suite passes with 200 tests — verified (200 of 200).
  • Claim: the new DateInput and DateTimeInput regressions and the existing caller-restore and retyped-date regressions pass — verified.
  • Claim: core typecheck passes — verified.
  • Claim: repository checks pass — verified for 25 of 28 checks; the three that read git history could not run in this review.
  • Claim: targeted ESLint and the whitespace check pass — verified.
  • Claim: pre-commit checks pass — not checked here.
  • Claim: one existing Korean hour-cycle failure in the full DateTimeInput suite — not reproduced (215 of 215 passed).
  • Claim: closes the linked issue — verified (its reproduction is the new test case).
  • Changeset: a core patch noting that both components clear rejected text when the controlled value is set to undefined — verified (matches the change; the changeset check passes).
  • File .changeset/date-input-clear-rejected-text.md — clear.
  • File packages/core/src/DateInput/useTypedDate.ts — clear (one optional comment suggestion).
  • File packages/core/src/DateInput/DateInput.test.tsx — clear.
  • File packages/core/src/DateTimeInput/DateTimeInput.test.tsx — clear.

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as draft November 20, 2026 18:19
@cixzhang
cixzhang marked this pull request as ready for review November 20, 2026 18:20
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 1d0c80b

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
DateTimeInput · Storybook 230.8 kB (+14 B) · 20.4 kB CSS (0) 3,691 (0) ✗ · ✓ · ✓
DateInput · Storybook 206.9 kB (+13 B) · 18.7 kB CSS (0) 6,363 (+5) ✗ · ✓ · ✓
PowerSearch 316.9 kB (+10 B) · 27.1 kB CSS (0) — — · — · —
Visual changes: 8 snapshots in 2 components

A change is a question for the reviewer, not a failure.

Component · story Before After Diff
DateInput · Open Calendar Audit (probe, dark) · inheritance unknown: not found in the 9 newest reports of other pull requests before frame after frame diff frame
DateInput · Open Calendar Audit (probe, light) · inheritance unknown: not found in the 9 newest reports of other pull requests before frame after frame diff frame
DateInput · Cleared Calendar Selection (neutral, light) · inheritance unknown: not found in the 9 newest reports of other pull requests before frame after frame diff frame
DateInput · Open Calendar Audit (neutral, light) · inheritance unknown: not found in the 9 newest reports of other pull requests before frame after frame diff frame
DateTimeInput · Cleared Calendar Selection (neutral, light) · inheritance unknown: not found in the 9 newest reports of other pull requests before frame after frame diff frame
DateInput · Cleared Calendar Selection (neutral, dark) · inheritance unknown: not found in the 9 newest reports of other pull requests before frame after frame diff frame
DateInput · Open Calendar Audit (neutral, dark) · inheritance unknown: not found in the 9 newest reports of other pull requests before frame after frame diff frame
DateTimeInput · Cleared Calendar Selection (neutral, dark) · inheritance unknown: not found in the 9 newest reports of other pull requests before frame after frame diff frame

Inheritance checked against the 9 newest reports of other pull requests.

Package size: @astryxdesign/core 7.86 MB packed (+145 B); no new dependencies.

Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.


Generated by PR Enrichment workflow | View full report

@cixzhang
cixzhang marked this pull request as draft November 20, 2026 18:52
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 1d0c80b

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved pending CI: CI has not run on this head yet. The ci:run label is applied, and the CI, CI review pass, Lint and CLI Smoke Test runs on this head are waiting for a maintainer to approve them.

A controlled value changed to undefined now empties kept rejected text, its invalid state and its message in DateInput and in DateTimeInput's date segment, as the rejected-entry spec already requires for any new value, while a value passed with the Enter or blur that keeps the text still keeps it. Both new tests fail without the fix and pass with it.

Claims and files checked

Review mode: full; reason: author-not-engowner

  • Claim (changeset and description): a controlled value changed to undefined clears rejected typed text in both components. Verified: DateInput.test.tsx:3050 and DateTimeInput.test.tsx:3733 fail without the change and pass with it, and a Chromium check of both clear-button stories shows the field empty with no error after Clear.
  • Claim: a value restored in the same Enter or blur update still keeps the rejected text. Verified: the existing restore tests pass, and a restore to undefined keeps the text too.
  • Claim: the cause is that no date had been reported, so undefined matched the last reported date. Verified in the base hook's value check.
  • Claim: after the clear, aria-invalid and the rejection message are removed. Verified by the new tests' assertions.
  • Claim: not a styling change. Verified: no style or token edits.
  • Claim: full DateInput suite 200 passed, both new regressions and the caller-restore regression pass, core typecheck, ESLint and the whitespace check pass. Verified by rerunning them.
  • Claim: one unrelated Korean hour-cycle failure in the full DateTimeInput suite. Not reproduced: all 215 DateTimeInput tests pass here.
  • Claim: closes the linked issue. Verified: its reproduction is the new DateInput test.
  • File .changeset/date-input-clear-rejected-text.md: clear.
  • File packages/core/src/DateInput/useTypedDate.ts: clear.
  • File packages/core/src/DateInput/DateInput.test.tsx: clear.
  • File packages/core/src/DateTimeInput/DateTimeInput.test.tsx: clear.

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as ready for review November 20, 2026 19:27
@cixzhang
cixzhang marked this pull request as draft November 20, 2026 19:33
@cixzhang
cixzhang marked this pull request as ready for review November 20, 2026 19:33
github-actions Bot added a commit that referenced this pull request Nov 20, 2026
@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Nov 20, 2026

This branch was successfully deployed

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

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] DateInput, DateTimeInput: a value cleared to undefined keeps rejected typed text

3 participants