Skip to content

feat(DateInput, DateTimeInput): add entryErrorBehavior for deferred rejection - #11281

Closed
bezabyte wants to merge 5 commits into
meta:mainfrom
bezabyte:fix/issue-10367-defer-date-errors
Closed

bezabyte wants to merge 5 commits into
meta:mainfrom
bezabyte:fix/issue-10367-defer-date-errors

Conversation

@bezabyte

@bezabyte bezabyte commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Primary intent

Add the opt-in entryErrorBehavior="blur-or-enter" behavior requested by #10367 while keeping the shipped complete behavior unchanged by default.

User impact

With the default entryErrorBehavior="complete", DateInput and DateTimeInput continue to reveal complete-date and native-control rejections immediately, as they did before this PR.

Consumers that choose entryErrorBehavior="blur-or-enter" get a quieter editing flow: typed date/time and native date/time rejections stay quiet while the value is being edited, then reveal on Enter or blur. If a revealed value is edited to another rejected value, the rejection stays visible without a second announcement until the next Enter or blur.

When deferred unreadable date text is kept in a pointer field, the visible input is removed from form submission and a hidden input carries the last committed date. The following Enter is therefore available to submit the surrounding form.

Authority

Change

  • Keep the existing complete default and add the public entryErrorBehavior option to both components.
  • Apply blur-or-enter consistently to typed date text, typed time text, and native date/time controls.
  • Preserve a revealed rejection across still-rejected edits without clearing the callback state or announcing the same failure again.
  • Add the public name prop to the date fields and preserve the committed form value while unreadable text is held.
  • Update generated prop documentation and the changeset to describe the opt-in feature.

Evidence

Interaction Existing complete default Opt-in blur-or-enter
Rejected typed date/time while editing Rejection is revealed immediately No rejection yet
Rejected native date/time control while focused Rejection is revealed immediately No rejection yet
Enter or blur Existing rejection behavior Rejection is revealed
Edit one revealed rejection into another rejected value Existing callback/announcement behavior Existing rejection remains without a duplicate announcement
Kept unreadable date text in a form Existing behavior Visible text is kept, committed date is submitted, and the next Enter can submit

This is a validation-state and form-semantics change rather than a layout change, so a screenshot would not reliably distinguish the states. The regression tests assert the user-visible value, aria-invalid, live-region messages, callback count, hidden form control, and Enter submission behavior.

Scope

Components: DateInput, DateTimeInput, native date/time segments, shared typed-date validation.

  • This PR has one primary intent.
  • Public docs and changeset match the shipped default and opt-in behavior.
  • No internal Meta context is included in public text.

Testing

  • Focused deferred behavior tests: 6 passed across DateInput, DateTimeInput, and native segment suites.
  • DateInput and DateTimeInput targeted suites: the existing Korean locale hour-cycle assertion remains the only unrelated failure; the new behavior tests pass.
  • pnpm -F @astryxdesign/core typecheck — passed.
  • Targeted ESLint and Prettier checks — passed.
  • Commit preflight (pnpm check:*, including changesets, package boundaries, i18n, fixtures, and sync checks) — passed.

The concrete review findings are addressed in e591746ef. The remaining maintainer action is the existing engineering-owner/spec approval gate and CI run label.

@vercel

vercel Bot commented Nov 11, 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 12, 2026 6:42pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 11, 2026
@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 11, 2026
@astracat-bot

astracat-bot Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🔴 Reviewed (for maintainers only) Nov 13, 2026, 3:35 PM UTC

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

This needs an engineering owner's decision before it can be approved, and one existing test needs updating.

  • Owner decision needed: the DateInput and DateTimeInput component specs (DateInput FR20/AR3, DateTimeInput FR11/AR5) require these rejections and their messages, but they do not say whether the error appears as soon as the typed date is complete (current behavior) or on Enter or blur (this PR). An engineering owner needs to settle that, for example by amending FR20 or by commenting /approve-spec with this PR's head commit. You are not expected to write the spec yourself.
  • Blocking: packages/core/src/DateTimeInput/DateTimeInput.calendar.test.tsx:92-100 ("shows an out-of-range error with the bounds in the calendar") now fails because it expects the error before Enter or blur. Assert that nothing shows after typing, then call fireEvent.blur(input) (or press Enter) before expectShown, as the updated DateInput tests do.

The DateInput side behaves as described: the edited tests fail without your change and pass with it, and after Enter or blur the field looks and reads exactly as before. Unreadable text such as abc still announces "Invalid date" immediately, so the owner decision should cover whether that difference is intended. CI has not run on this head yet; a maintainer adds the ci:run label so it runs.

Automated review (maintainer link)

@bezabyte

Copy link
Copy Markdown
Contributor Author

Applied the concrete test correction from review in 700391a31: the out-of-range calendar assertion now blurs the input before expecting the committed error state, matching the deferred-validation behavior. The focused calendar suite passes. The remaining open question is the owner decision on the exact error timing contract (immediate vs commit), which the implementation should not guess beyond the current review direction.

@bezabyte

Copy link
Copy Markdown
Contributor Author

Updated the branch at d01108e and rebased it onto current main.

The requested DateTimeInput calendar test now stays silent after typing the out-of-range value and asserts the bounds message only after blur. While rerunning the full date suites, I also found and corrected two stale DateInput assertions for provider-calendar invalid dates and date constraints; both now verify no error while typing and the expected announcement after blur.

Verification:

  • DateInput.calendar.test.tsx plus DateTimeInput.calendar.test.tsx: 52 passed
  • Full repository pre-commit checks: passed

The remaining item is the engineering-owner decision on whether nonexistent and out-of-range typed dates should be announced on Enter or blur; the implementation and tests now consistently enforce the proposed behavior.

@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 DateInput and DateTimeInput specs now keep today's error timing as the default, so this change needs to become the opt-in option the maintainers chose.

  • Regression: since the last review, the maintainers ruled on #10367 and recorded in the DateInput spec (FR24 and FR25, which DateTimeInput FR15 and FR16 follow) that, by default, a nonexistent or out-of-range typed date still shows its error as soon as it is complete, so making typedDateError wait for Enter or blur for every field (packages/core/src/DateInput/useTypedDate.ts:148-152), with the test edits and changeset that assert it, now contradicts the spec: restore (result.isComplete || isCommitted) as the default and deliver the deferral under entryErrorBehavior="blur-or-enter" as FR24 describes, or close this in favour of that work.

The earlier failing DateTimeInput out-of-range test is fixed at this head. You do not need to write or change a spec: the option's contract is already recorded. CI has not run on this head yet; a maintainer adds the ci:run label so it runs.

Automated review (maintainer link)

@bezabyte
bezabyte force-pushed the fix/issue-10367-defer-date-errors branch from d01108e to 3f1e71e Compare November 12, 2026 16:15
@bezabyte

Copy link
Copy Markdown
Contributor Author

Addressed the latest validation-timing review in 3f1e71e.

  • Restored the shipped complete behavior as the default, including immediate complete-date rejection.
  • Added the public entryErrorBehavior prop and exported EntryErrorBehavior type.
  • entryErrorBehavior="blur-or-enter" now holds unreadable, incomplete, nonexistent, and out-of-range rejection signals until Enter or blur, including the callback report; valid or empty edits clear the rejection immediately.
  • Updated DateInput/DateTimeInput docs, changeset wording, and calendar regression coverage.

Verification: calendar suites pass (54/54), the DateInput/DateTimeInput entry-error tests pass, and Core typecheck plus repository pre-commit checks pass. The maintainer/spec-owner gate remains open on the PR.

@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 new entryErrorBehavior prop, its 'complete' default and the exported EntryErrorBehavior type match the option chosen on #10367, but 'blur-or-enter' does not yet behave as the DateInput and DateTimeInput specs describe.

  • DateTimeInput's time segment and native segments ignore the prop: under 'blur-or-enter' the time field still sets aria-invalid and announces "Invalid time" on every keystroke (DateTimeInput.tsx:878-887, :2006-2024), while DateTimeInput FR15 says both segments follow it, and the prop's docs narrow it to "the date segment".
  • Under 'blur-or-enter', editing a revealed rejection to another rejected date (2/30/2026 to 2/31/2026) hides the error and calls onEntryErrorChange(null), because handleChange clears the commit flag on every edit (useTypedDate.ts:628-640); DateInput FR24 keeps the error, without a new announcement, until the next Enter or blur.
  • DateInput's native control never receives the prop (DateInput.tsx:1189-1190), so on a coarse pointer it still marks and announces a refused date at once, although FR24 holds native rejections until blur and the prop's JSDoc says every signal is held.
  • Under 'blur-or-enter', kept unreadable text stays pending (useTypedDate.ts:670-689), so a form posts the typed text under the field's name and Enter never submits, while FR25, which FR24 applies here, puts the committed date in a hidden input and lets the next Enter submit.
  • The title, description and changeset still describe a fix that defers errors by default: please retitle (for example feat(DateInput, DateTimeInput): add entryErrorBehavior to hold typed-date errors until Enter or blur), tag the changeset [feat] as other new props are, and update the description's Change and Evidence sections.

Tests for an edit after a revealed rejection, a native edit and the time segment under 'blur-or-enter' would cover these cases. Smaller notes are inline.

Claims and files checked
  • Changeset: both components support an opt-in 'blur-or-enter' that holds typed rejection signals until Enter or blur, keeping the 'complete' default. Partly false: only typed date text is held, not DateTimeInput's time segment or the native controls, and [fix] labels a new option.
  • Description: fixes #10367 by deferring nonexistent and out-of-range errors until commit. False as a default; true only under the new value.
  • Description: before the change, a complete invalid date showed an error while typing. True, and still true by default.
  • Description: that did not match the commit timing of unreadable text. Partly false: unreadable text is already announced at once; only its visible status waits.
  • Description: nonexistent and out-of-range results stay quiet while editing. True under 'blur-or-enter' (useTypedDate.ts:146-148), but an edit also hides a revealed rejection.
  • Description: those errors show and are announced at Enter or blur. Verified for typed text (useTypedDate.ts:697-707).
  • Description: immediate handling of unreadable input is preserved. True by default; false under 'blur-or-enter', which holds it.
  • Description: onChange for valid dates is unchanged. Verified (useTypedDate.ts:641-646).
  • Description: regression coverage for Gregorian, Japanese, Persian and Buddhist calendars. Verified (DateInput.calendar.test.tsx).
  • Description: a patch changeset for core. Verified.
  • Description evidence table: no error while typing a complete nonexistent or out-of-range date. False by default; true under 'blur-or-enter'.
  • Description testing results (suites, typecheck, lint, pre-commit). Not verified: CI has not run on this head.
  • Files: .changeset/defer-date-rejection-until-commit.md ([fix] tag); DateInput.calendar.test.tsx (clear; default calendar cases now run only under the new value); DateInput.doc.mjs (promises every signal is held, native control); DateInput.tsx (native control); DateInput/index.ts (clear); useTypedDate.ts (edit after a revealed rejection, kept unreadable text); DateTimeInput.calendar.test.tsx (clear); DateTimeInput.doc.mjs (scopes the prop to the date segment); DateTimeInput.tsx (time segment and native segments); DateTimeInput/index.ts (clear).

Automated review (maintainer link)

Comment on lines +674 to +676
// Keep a rejection that was held while typing long enough to explain it
// at the commit that reveals it. The shipped complete behavior continues
// to drop unreadable text after announcing it while typing.

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.

Non-blocking (comment style): "long enough to explain it" is vague, and the second sentence narrates another branch. Suggested: "Unreadable text stays so the commit can show why. Under 'complete', the code below drops it."

it('reads Japanese era dates and rejects a year outside its era', () => {
const {input, onChange, container} = renderField('en', {
calendar: 'japanese',
entryErrorBehavior: 'blur-or-enter',

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.

Non-blocking: this and five other existing rejection cases now run only under 'blur-or-enter', and "announces a different message for each kind of rejection" commits before it asserts, so the calendar suites no longer check the default's immediate reveal for these calendars. Running each case under both values keeps both timings covered.

@bezabyte bezabyte changed the title fix(date-input): defer rejected date errors until commit feat(DateInput, DateTimeInput): add entryErrorBehavior for deferred rejection Nov 12, 2026
@bezabyte

Copy link
Copy Markdown
Contributor Author

Addressed the concrete requested changes in e591746ef.

  • Kept entryErrorBehavior="complete" as the unchanged default; the deferred behavior is opt-in.
  • Applied blur-or-enter to typed date, typed time, native date, and native time rejection states.
  • Kept a revealed rejection stable across still-rejected edits without a new callback or announcement.
  • Preserved the committed form value for kept unreadable text and added the public name prop needed for that form behavior.
  • Added regression coverage for deferred typed date/time, native date/time, form submission, and the edit-after-rejection path.
  • Updated source/generated docs, the changeset, PR title, and PR evidence table.

Verification: focused deferred tests 6/6 passed; Core typecheck, targeted ESLint/Prettier, and commit preflight passed. The unrelated existing Korean locale hour-cycle assertion remains the only failure in the broader DateTimeInput suite.

The engineering-owner/spec approval gate and ci:run maintainer action remain open on the PR.

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

Recommending that this pull request be closed: #11485, merged to main on 2026-11-13, already ships entryErrorBehavior on DateInput and DateTimeInput (and on TimeInput, with FormLayout's defaultEntryErrorBehavior), and this branch now conflicts with main. Thank you for pushing #10367 forward; the behavior built here is what main now provides. If you find a case that main's version still gets wrong, a new, focused pull request from main is the way to land it.

  • Regression: since the last review, #11485 landed the same prop, type and release note on main, and this branch conflicts with it in 9 files (DateInput.tsx, DateInput.doc.mjs, useTypedDate.ts, NativeDateField.tsx, NativeDateField.test.tsx, DateTimeInput.tsx, DateTimeInput.doc.mjs, NativeDateSegment.tsx, NativeTimeSegment.tsx), so nothing here remains to land.
  • Regression: the field resolves only its own prop, else 'complete' (DateInput.tsx:612, DateTimeInput.tsx:709), while the validation-timing spec (AST-117 FR2, DateInput FR24) also reads the nearest FormLayout's defaultEntryErrorBehavior.
  • Under 'blur-or-enter', Enter in a native date or time control reveals nothing until blur (NativeDateField.tsx:403-405 and both native segments), while AST-117 FR4 holds a native value only to the next Enter or blur.
  • Under 'blur-or-enter', the time segment's first Enter on a rejected time blocks the form's submission (DateTimeInput.tsx:1690-1696, asserted by the new form test), while DateTimeInput FR16 says Enter there commits and is not prevented beyond that, so the form submits.
Claims and files checked
  • Changeset: both components get an opt-in 'blur-or-enter' that holds typed and native rejections until Enter or blur, keeping the 'complete' default. Partly false: native controls hold only until blur (NativeDateField.tsx:403-405), and main already carries a release note for this feature.
  • Description: the shipped complete behavior stays the default. True for rejection timing ("keeps complete-date rejection immediate by default"); under the default, Enter in the time segment now also commits the typed time (DateTimeInput.tsx:1672-1689).
  • Description: the default still reveals complete-date and native rejections immediately. Verified (useTypedDate.ts:149-161; native 'complete' path unchanged).
  • Description: under 'blur-or-enter', typed and native rejections stay quiet while editing and appear at Enter or blur. True for typed dates and times (new tests pass); false for Enter on native controls.
  • Description: editing a revealed rejection into another rejected value keeps it without a second announcement. Verified for aria-invalid and the callback ("keeps a revealed rejection when another rejected date is edited"); the announcement is not asserted.
  • Description: kept unreadable text leaves form submission, a hidden input carries the committed date, and the next Enter submits. Verified for DateInput ("keeps the committed form value while deferred unreadable text is shown"); DateTimeInput's copy is untested.
  • Description: adds a public name prop. Verified: name?: string is new on both prop types.
  • Description: docs and changeset updated. Verified; the .doc.mjs files are authored docs.
  • Description evidence table. Matches the code except native Enter and the time segment's form submission.
  • Description testing results. The six changed test files pass here (482 tests); the reported Korean locale failure did not reproduce in them.
  • Files: .changeset/defer-date-rejection-until-commit.md (duplicates main's release note); DateInput.calendar.test.tsx (clear); DateInput.doc.mjs (conflicts); DateInput.test.tsx (clear); DateInput.tsx (FormLayout default, conflicts); NativeDateField.test.tsx (blur only, conflicts); NativeDateField.tsx (native Enter, conflicts); DateInput/index.ts (clear); useTypedDate.ts (second EntryErrorBehavior, conflicts); DateTimeInput.calendar.test.tsx (clear); DateTimeInput.doc.mjs (conflicts); DateTimeInput.test.tsx (asserts the blocked first Enter); DateTimeInput.tsx (time-segment Enter, FormLayout default, conflicts); NativeDateSegment.tsx and NativeTimeSegment.tsx (native Enter, conflict); NativePickerSegments.test.tsx (blur only); DateTimeInput/index.ts (clear).

Automated review (maintainer link)

@bezabyte

Copy link
Copy Markdown
Contributor Author

Closing this branch because #11485 is merged to main and already ships the entryErrorBehavior implementation for DateInput, DateTimeInput, TimeInput, and FormLayout. Keeping this PR open would duplicate and conflict with the shipped code. Any remaining regression should be raised as a new focused PR from current main.

@bezabyte bezabyte closed this Nov 14, 2026

This branch was successfully deployed

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

2 participants