Skip to content

fix(DateInput, DateTimeInput): a value passed at the revealing commit keeps the rejected date entry - #11470

Merged
nynexman4464 merged 4 commits into
mainfrom
nynexman4464/fix/date-commit-value-keeps-entry
Nov 13, 2026
Merged

nynexman4464 merged 4 commits into
mainfrom
nynexman4464/fix/date-commit-value-keeps-entry

Conversation

@nynexman4464

@nynexman4464 nynexman4464 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

User impact

People who type a date into a DateInput, or into the date segment of a DateTimeInput, inside an app that restores its own value at an Enter or blur that ends an edit. A live filter does this when it puts back the date it had before the edit. When the person's text was rejected (unreadable, incomplete, a date the calendar does not have, or outside min, max, or dateConstraints), the field dropped the text, its message, and aria-invalid in that same update, and reported null through onEntryErrorChange. The person lost what they typed with no message, and could not correct it. A native date control lost its rejection message the same way after it restored the committed date.

After this change the rejected text, its rejection, and its message stay at every Enter or blur that keeps them, a blur after an Enter included, so the person can correct the entry, and nothing is reported. A later new value replaces the text, as before.

Problem and solution fit

  • Why does the defect occur? useTypedDateField dropped typed text on every new value. It could not tell a value that arrives in the same update as a commit that keeps rejected text from a later replacement. useNativeDateRejection ended its rejection on every new value in the same way.
  • Why does it harm the task? A commit that keeps rejected text exists so the person can see why it was refused and fix it. Dropping the text in the same update discards the entry silently, which is what spec:AST-118 FR4 and AR4 forbid.
  • Why does that harm matter? Keeping an invalid entry with a chance to correct it is preferred to removing it (spec:AST-118 DEC-14), and a silent discard fails WCAG 2.2 3.3.1 (Error Identification).

One internal hook, Field/useValueReplacesEntry, now holds the rule for DateInput's typed field, its native rejection, and NumberInput. It takes the field's value and one signal that changes at each Enter or blur that keeps rejected text, and returns whether a new value replaces the kept entry. A value that arrives in the same update as a change of that signal does not replace the entry. A value that changes in any later update still replaces it.

Expected behavior and authority

  • spec:AST-118 FR4, FR6, FR8, and DEC-14: a value that the caller passes in the same update as an Enter or blur that keeps rejected text does not replace the kept entry; the text, its rejection, and its message stay, nothing is reported, and a later new value replaces it.
  • This PR broadens DEC-14 from "the Enter or blur that reveals the rejection" to "an Enter or blur that keeps rejected text", the first or a later one. This follows the owner's rule to prefer keeping invalid input with a chance to correct it. With the narrower wording, Enter followed by a blur that restores the value still erased the text. NumberInput FR3 uses the same wording, and NumberInput already kept its draft at every keeping commit. DEC-14 records the narrower rule as rejected.
  • spec:AST-118 listed the mismatch as "FR4, FR6 gap: DateInput drops kept date text and its rejection when the caller passes a new value in the same update as the Enter or blur that reveals the rejection." This PR removes that line.
  • component:DateInput FR25 states the rule. component:DateTimeInput FR16 sends the date segment to DateInput FR25.
  • family:input-fields names useValueReplacesEntry in its Shared owner section, next to useEntryErrorReport.

Smallest restoration

  • packages/core/src/Field/useValueReplacesEntry.ts (new internal hook, not exported): a render-phase record of the last value and keep signal. It returns true in one render per new value at most, and false when the keep signal changed in the same update.
  • packages/core/src/DateInput/useTypedDate.ts:
    • useTypedDateField (DateInput and DateTimeInput's date segment) counts each Enter or blur that keeps rejected text and passes that count as the keep signal. A new value still retires the date that typing last reported, so a date typed again after the restore reports again.
    • useNativeDateRejection counts each Enter and blur, which shows a refused date that stands, and passes that count.
  • packages/core/src/NumberInput/NumberInput.tsx calls the same hook with its shown rejection. Each keeping commit sets a new rejection, so behavior does not change. It is a separate commit.
  • useEntryErrorReport is unchanged. Because the rejection does not change, it reports nothing.
  • Records: AST-118 FR4, FR6, FR8, DEC-14 and its path list, and the FR6 verification row; DateInput FR25 and its verification row; NumberInput FR3 (wording only, same length); the DateTimeInput FR16 verification row; and the family:input-fields Shared owner section and verified_by.
  • Tagalongs that were asked for: two source-comment fixes under INV29, in a separate commit, with no behavior change. In NumberInput, the comment over its shown rejection reads "A number has no fixed length, so only Enter or blur shows a rejection." In Pagination, the comment over its rejected-entry state keeps only the reason.
  • Not changed: TimeInput and DateTimeInput's time segment. The open TimeInput rejected-entry PR owns those paths and keys its draft on every keeping commit. Once it merges, TimeInput can switch to the shared hook.

Evidence

  • Reproduction before the change:
    • The 13 DateInput and DateTimeInput tests named below, run against main's useTypedDate.ts, give 11 failed | 2 passed. The two that pass guard paths that already worked: a date typed again after the restore reports again, and a later new value ends a native rejection.
    • Against the previous head (first keeping commit only), 2 of the 13 fail. These are the two Enter-then-blur tests, typed and native.
  • Result after the change: all 13 pass, and so do the 5 hook tests.
  • Representative unchanged path: "reports null when a new value drops the typed text", "clears pending input when value changes externally", "posts the committed date from a hidden input while Enter or blur keeps unreadable text", NumberInput's rejected-entry suites, and the Table inline-filter tests all pass unchanged.
  • Regression test or other mutation-sensitive proof: 14 mutations of the hook and of the three members that call it (below). Each one makes at least one test fail.

Scope

Components: DateInput, DateTimeInput, Field (internal hook), NumberInput (internal refactor and comment), Pagination (comment only)

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

New tests:

  • DateInput.test.tsx
    • "keeps %s text and its message when the caller restores its value at the %s that keeps it" (unreadable and nonexistent text; blur and Enter)
    • "keeps text that Enter kept when the caller restores its value at the next blur, and reports nothing"
    • "reports a retyped date again after the caller restores its value at the blur that keeps the text"
    • "posts the restored date from a hidden input when the caller restores its value at the blur that keeps unreadable text"
    • "reports nothing when the caller restores its value at the blur that keeps the text, and null once a later value replaces it"
  • NativeDateField.test.tsx
    • "keeps a refused date shown when the caller restores its value at the blur that shows it"
    • "keeps a refused date that Enter showed when the caller restores its value at the next blur"
    • "ends a shown rejection when a later new value replaces it"
  • DateTimeInput.test.tsx
    • "keeps unreadable date text and its message when the caller restores its value at the %s that keeps it" (blur and Enter)
  • Field/useValueReplacesEntry.test.tsx: 5 cases (a new value; a value with a new keep signal, then a later value; every keep signal, not only the first; a keep signal alone; Object.is for NaN)
# DateInput and DateTimeInput tests above, against main's useTypedDate.ts
$ pnpm exec vitest run --project ui packages/core/src/DateInput/DateInput.test.tsx \
    packages/core/src/DateInput/NativeDateField.test.tsx packages/core/src/DateTimeInput/DateTimeInput.test.tsx \
    -t "restores its value|later new value replaces it"
      Tests  11 failed | 2 passed | 411 skipped (424)

# Same command, against the previous head's useTypedDate.ts (first keeping commit only)
      Tests  2 failed | 11 passed | 411 skipped (424)
     × keeps a refused date that Enter showed when the caller restores its value at the next blur
     × keeps text that Enter kept when the caller restores its value at the next blur, and reports nothing

# Same command, with this change
      Tests  13 passed | 411 skipped (424)

# Targeted suites: DateInput, DateTimeInput, DateRangeInput, PowerSearch, NumberInput, Pagination, TimeInput, Table filtering, Field
$ pnpm exec vitest run --project ui packages/core/src/DateInput packages/core/src/DateTimeInput \
    packages/core/src/DateRangeInput packages/core/src/PowerSearch packages/core/src/NumberInput \
    packages/core/src/Pagination packages/core/src/TimeInput packages/core/src/Table/plugins/filtering packages/core/src/Field
 Test Files  73 passed (73)
      Tests  2679 passed (2679)

# Full core suite
$ pnpm exec vitest run --project ui packages/core
 Test Files  852 passed (852)
      Tests  22956 passed (22956)

$ pnpm exec tsc --noEmit -p packages/core                         # 0 errors
$ ASTRYX_STRICT_LINT=1 pnpm exec eslint <changed .ts/.tsx>         # 0 errors (1 existing warning on main: unused BaseProps import in NumberInput.tsx)
$ pnpm exec prettier --check <changed files>                       # All matched files use Prettier code style!
$ pnpm check:knowledge                                             # Knowledge templates and records are aligned.
$ pnpm check:changesets                                            # 138 changeset(s) valid; main declares 0.7.16 (patch plan)
$ node scripts/release/changeset-coverage.mjs pr --base origin/main --head HEAD --released v0.7.15
✓ Changeset coverage — ships to @astryxdesign/core, each named; released CLI JSON ids checked against v0.7.15
$ pnpm check:sync                                                  # All SYNC comments are clean.
$ pnpm specs:for packages/core/src/Field/useValueReplacesEntry.ts  # links family:input-fields, spec:AST-118, component:Field
$ pnpm review:pre
Authored lines: 545 (guideline 2000; lockfiles, snapshots, and generated files excluded)
Merge into origin/main: clean
Findings in this change (0): none

Mutation checks. Each row changes the hook or one member in one place. The hook, DateInput, NativeDateField, DateInput calendar, DateTimeInput, NativePickerSegments, NumberInput, Table filtering, and Pagination suites run (1047 tests unmutated). At least one test fails each time.

Mutation Failing tests
Hook ignores the keep signal 16
Hook inverts the keep signal 31
Hook never records the render 17
Hook never sees a keep signal 16
Hook compares values with !== in place of Object.is 1
Typed: a keeping commit sends no signal 9
Typed: signal at the first keeping commit only (the previous head) 1
Typed: every new value drops the text 9
Typed: a new value keeps the date typing last reported 1
Native: Enter and blur send no signal 2
Native: a new value never ends the rejection 2
Native: signal only when a new refused date shows (the previous head) 1
NumberInput: no keep signal 3
NumberInput: a new value never replaces the draft 5

No real-browser run: the change is React state only. It does not depend on layout, pixels, focus order, scrolling, hit testing, or input modality, and the jsdom suites cover it.

Writing rubric results

Records touched: spec:AST-118 (FR4, FR6, FR8, DEC-14, path list, gap list, FR6 verification row), component:DateInput (FR25 and its verification row), component:NumberInput (FR3), component:DateTimeInput (FR16 verification row), and family:input-fields (Shared owner section and verified_by).

R1 narration: none. The amended FR4, FR6, FR8, and DEC-14 sentences ("an Enter or blur that keeps rejected text", "the first or a later one"), the DateInput FR25 clause, the NumberInput FR3 wording ("any Enter or blur that keeps the rejection"), and the family bullet for useValueReplacesEntry state what the system does, in the present tense.
R2 research: none.
R3 evidence: the verification cells name test files and cases; none names a pull request, issue, or commit.
R4 rejected alternatives: one, inside DEC-14, one line: "Rejected: sparing only the commit that reveals the rejection, because Enter and then a blur that restores the value would erase the text." It stays because naming it prevents the narrower rule from coming back.
R5 change references: none (searched for # followed by digits, /pull/, and /issues/).
R6 open questions: none.
R7 project status: the spec:AST-118 line "FR4, FR6 gap: DateInput drops kept date text and its rejection…" is removed, because DateInput and DateTimeInput's date segment keep the entry. No gap is added. The DateInput and DateTimeInput records had no matching gap.

…s a rejected date keeps it

When an app set value in the same update as the Enter or blur that kept
rejected date text, as an app does when it restores the date it had
before the edit, DateInput and DateTimeInput's date segment dropped the
text, its message, and aria-invalid, and reported null through
onEntryErrorChange. A native date control lost its rejection message the
same way.

A value that changes in the update where Enter or blur keeps rejected
text, or shows a native rejection, now leaves the text and the rejection
in place and reports nothing. A later new value replaces the text, as
before, and a date the person types again after the restore reports
again.

AST-118 no longer lists the DateInput FR4, FR6 gap. DateInput FR25
states the rule, and the DateInput and DateTimeInput verification rows
name the new tests.
NumberInput's comment over its shown rejection and Pagination's comment
over its rejected-entry state no longer restate the state's name; each
keeps only the reason.
@vercel

vercel Bot commented Nov 13, 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 13, 2026 4:24am UTC

Request Review

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

Copy link
Copy Markdown
Contributor Author

/approve-spec 3c0bf98

@astracat-bot

astracat-bot Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 13, 2026, 4:47 AM UTC

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

Current run: The current CI run concluded skipped. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

@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.

Changes requested: the fix works for a value passed at the Enter or blur that reveals a rejected date, but the release note and record promise more than the code does, and two smaller issues need fixing.

  • The changeset and the new DateInput FR25 clause say a value passed at "the Enter or blur that keeps" a rejected date no longer erases it, yet useTypedDate.ts spares only the first keeping commit, so a caller that restores at blur still erases the text, its message and aria-invalid (and reports null) when the person presses Enter and then leaves the field; either say "the Enter or blur that reveals the rejection", as AST-118 FR4 and DEC-14 do, or key the rule on every keeping commit and add a test for Enter then blur.
  • The new rule in useTypedDateField and useNativeDateRejection copies NumberInput's render-phase rule with a different key, and the copies already disagree (after Enter then a blur that sets value, NumberInput keeps its draft while DateInput erases its text), so move the rule into one shared helper beside useEntryErrorReport that all three members call once.
  • The changeset names no accessibility target, which AST-017 FR53 requires for an accessibility behavior fix; add the success criterion it serves (WCAG 2.2 3.3.1, Error Identification), as the earlier AST-118 changesets do.

The new tests fail on main and pass here, and the targeted suites, typecheck, lint and knowledge checks are clean. Two new source comments run past the 25-word sentence limit; inline suggestions show shorter wording.

Claims and files checked
  • Claim: patch [fix] for @astryxdesign/core (verified, changeset front matter).
  • Claim: a value passed at the Enter or blur that keeps a rejected date no longer erases it (verified for the revealing commit by the new tests; false for Enter then a restoring blur).
  • Claim: a native control keeps its rejection message the same way (verified for the blur that shows it; false for Enter then a restoring blur).
  • Claim: nothing is reported when the caller restores (verified at the revealing commit; false after Enter then a restoring blur, which reports null).
  • Claim: a later new value replaces the text (verified, Replace steps in the new tests).
  • Claim: no app code changes are needed (verified, built API surface unchanged).
  • Claim: the new tests give 9 failed and 2 passed against main's hook, and 11 passed with the fix (verified).
  • Claim: the targeted suites pass, 72 files and 2672 tests (verified); typecheck, lint with one existing warning, Prettier, knowledge and changeset checks pass (verified).
  • Claim: useEntryErrorReport, TimeInput and the time segment are unchanged (verified, diff).
  • Claim: a date typed again after the restore reports again (verified, new test).
  • Claim: the gap line is removed, FR25 states the rule and the verification rows name the new tests (verified; the FR25 wording is the first finding).
  • Claim: NumberInput and Pagination change comments only (verified).
  • Claim: 334 authored lines (verified).
  • Claim: each listed mutation fails at least one test (not re-run).
  • File .changeset/date-commit-value-keeps-entry.md: first and third findings.
  • File docs/specs/AST-118-rejected-entry-feedback/spec.md: clear.
  • File docs/specs/components/DateInput/DateInput.spec.md: first finding (FR25 wording).
  • File docs/specs/components/DateTimeInput/DateTimeInput.spec.md: clear.
  • File packages/core/src/DateInput/DateInput.test.tsx: clear; no case for a value at a second keeping commit (first finding).
  • File packages/core/src/DateInput/NativeDateField.test.tsx: clear.
  • File packages/core/src/DateInput/useTypedDate.ts: first and second findings; comment-length suggestions.
  • File packages/core/src/DateTimeInput/DateTimeInput.test.tsx: clear.
  • File packages/core/src/NumberInput/NumberInput.tsx: clear.
  • File packages/core/src/Pagination/Pagination.tsx: clear.

Automated review (maintainer link)

…eps a rejected date keeps it

A value that the caller passed with a blur after an Enter that already
kept rejected date text still erased the text, its message, and
aria-invalid, and reported null: only the first keeping commit spared
the entry. A native date control lost its rejection the same way when a
blur followed the Enter that showed it.

A new internal hook, Field/useValueReplacesEntry, decides whether a new
value replaces a kept entry. It takes the value and a signal that
changes at each Enter or blur that keeps rejected text, and returns
false for a value that arrives in the same update as that signal.
DateInput's typed field counts each keeping commit, and its native
rejection counts each Enter and blur, so a value at any of them keeps
the entry. A later new value still replaces it.

AST-118 FR4, FR6, FR8, and DEC-14 now say "an Enter or blur that keeps
rejected text" in place of "the Enter or blur that reveals the
rejection", following the owner's rule to prefer keeping invalid input
with a chance to correct it. NumberInput FR3 matches. The input-fields
family names the hook in its Shared owner section.

The Changeset names WCAG 2.2 3.3.1 (Error Identification) as the
accessibility target.
…ces a kept draft

NumberInput kept its own copy of the rule that DateInput now takes from
Field/useValueReplacesEntry. It passes its value and its shown
rejection, which each Enter or blur that keeps a draft sets anew, so the
three members stay in step.

No behavior change.
@nynexman4464

Copy link
Copy Markdown
Contributor Author

/approve-spec da3d8f5

@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: the required checks are still queued or running on this head.

The three points from the previous review are resolved: a value restored at a blur after Enter now keeps the typed text and the native rejection, useValueReplacesEntry is the one owner of the rule for DateInput, DateTimeInput's date segment and NumberInput, and the changeset names WCAG 2.2 3.3.1. The new restore tests fail against main and pass here, and the targeted suites, typecheck, lint, formatting and knowledge checks are clean.

Optional: the title still says "at the revealing commit"; "a value at any Enter or blur that keeps a rejected date keeps it" would match the changeset and the decision record.

Claims and files checked
  • Claim: a patch [fix] for @astryxdesign/core (verified, changeset front matter).
  • Claim: a value the app passes at any Enter or blur that keeps a rejected date no longer erases it, a blur after an Enter included (verified: the new tests pass here and fail against main; the two Enter-then-blur tests also fail against the previous revision).
  • Claim: before, the field dropped the text, its message and aria-invalid and reported null (verified: the red-first run reports null at the restore).
  • Claim: a native date control lost its rejection message the same way and now keeps it (verified: native tests and a Chromium capture).
  • Claim: nothing is reported when the app restores, and a later new value replaces the text (verified: report and Replace steps in the new tests).
  • Claim: the changeset names the accessibility target, WCAG 2.2 3.3.1 (verified).
  • Claim: no app code changes are needed (verified: the built API surfaces of Core and the themes are unchanged).
  • Claim: unreadable, incomplete, nonexistent and out-of-range text all take the kept path (verified: one keeping branch in useTypedDate.ts; tests cover unreadable and nonexistent text).
  • Claim: one internal hook holds the rule for the typed field, the native rejection and NumberInput, returns true at most once per new value, and false when the keep signal changed in the same update (verified: hook code and its 5 tests).
  • Claim: NumberInput behaves as before (verified: equivalent logic, NumberInput suites pass).
  • Claim: useEntryErrorReport, TimeInput and the time segment are unchanged, and an open TimeInput pull request owns those paths (verified: diff; such a pull request is open).
  • Claim: the 13 restore tests give 11 failed and 2 passed against main's hook, 2 failed against the previous revision, and 13 passed here (verified).
  • Claim: the targeted suites, typecheck, lint with one existing warning, Prettier, knowledge, changeset and SYNC checks pass (verified; targeted suites re-run over the DateInput, DateTimeInput, NumberInput, Field, Pagination, TimeInput, Table filtering and DateRangeInput folders).
  • Claim: the full Core suite and the changeset coverage script pass (not re-run).
  • Claim: each of the 14 listed mutations fails at least one test (4 spot-checked, each fails at least one test).
  • Claim: 545 authored lines and a clean merge into main (verified).
  • Claim: the records change as listed, the NumberInput FR3 row keeps its length, and the NumberInput and Pagination comment rewrites change no behavior (verified).
  • File .changeset/date-commit-value-keeps-entry.md: clear.
  • File docs/families/input-fields.md: clear.
  • File docs/specs/AST-118-rejected-entry-feedback/spec.md: clear.
  • File docs/specs/components/DateInput/DateInput.spec.md: clear.
  • File docs/specs/components/DateTimeInput/DateTimeInput.spec.md: clear.
  • File docs/specs/components/NumberInput/NumberInput.spec.md: clear.
  • File packages/core/src/DateInput/DateInput.test.tsx: clear.
  • File packages/core/src/DateInput/NativeDateField.test.tsx: clear.
  • File packages/core/src/DateInput/useTypedDate.ts: clear.
  • File packages/core/src/DateTimeInput/DateTimeInput.test.tsx: clear.
  • File packages/core/src/Field/useValueReplacesEntry.test.tsx: clear.
  • File packages/core/src/Field/useValueReplacesEntry.ts: clear.
  • File packages/core/src/NumberInput/NumberInput.tsx: clear.
  • File packages/core/src/Pagination/Pagination.tsx: clear.

Automated review (maintainer link)

This branch was successfully deployed

1 active deployment
Preview — da3d8f58 Deployed Nov 13, 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant