Repository navigation
feat(DateInput, DateTimeInput, TimeInput, FormLayout): entryErrorBehavior and a form default - #11485
Conversation
…vior and a form default
DateInput, DateTimeInput, and TimeInput take `entryErrorBehavior`
('complete' | 'blur-or-enter'), and FormLayout carries
`defaultEntryErrorBehavior` on its layout context. A field resolves its
own prop, else the nearest FormLayout default, else 'complete'.
Under 'blur-or-enter', typing and native time edits reveal no rejection of
the field's own; Enter or blur reveals the entry's current rejection with
every signal together and one announcement, and the onEntryErrorChange
report moves to that commit. An edit that the field accepts or empties
clears at once. PowerSearch value editors and Table filter editors keep
'complete'.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec 5b3078b |
PR Analysis Report
Generated by PR Enrichment workflow | View current CI run |
There was a problem hiding this comment.
Approved pending CI: CI is still running on this head.
entryErrorBehavior on DateInput, DateTimeInput and TimeInput, and FormLayout's defaultEntryErrorBehavior, follow the entry error behavior spec: unset, each field keeps its current timing, and under 'blur-or-enter' the message, aria-invalid, invalid styling, announcement and onEntryErrorChange report wait for Enter or blur, which a real-browser check of DateInput, the typed TimeInput and the native time control confirms.
Non-blocking: the native time control's new Enter and blur commit (NativeTimeSegment.tsx) is covered only by jsdom tests; a TimeInput presentation="native" case in the interaction browser spec would keep it proved in Chromium and WebKit, as the spec's platform-support section asks.
Claims and files checked
Claims
- The three fields take
entryErrorBehaviorand FormLayout takesdefaultEntryErrorBehavior: verified (DateInput.tsx:407,DateTimeInput.tsx:565,TimeInput.tsx:429,FormLayout.tsx:138). - The prop sets when a field's own error shows, not when validation runs: verified (parsing still runs on every edit; only the reveal is gated,
useTypedDate.ts:148,useTypedTime.ts:212-216). 'complete', the default, keeps each field's current timing: verified (useEntryErrorBehavior.ts:33; existing suites pass unchanged; new unset and'complete'cases).'blur-or-enter'holds the message,aria-invalid, styling, announcement and report until Enter or blur: verified (new keystroke cases in the DateInput, DateTimeInput and TimeInput tests; real-browser check).- An edit that makes the entry valid or empty clears the error at once: verified ("clears a revealed rejection and reports null at once" and the time suites).
- An edit that leaves the entry wrong keeps the shown error without a new announcement until the next commit: verified ("keeps a revealed rejection through edits that stay wrong").
- A field's own prop wins, a nested FormLayout replaces the default, and a Dialog opened from the form starts without it: verified (
FormLayout.test.tsxprecedence cases). - PowerSearch value editors and Table filter editors keep
'complete': verified (PowerSearchValueEditor.tsx:499,:570,:582,:635;useTableFiltering.tsx:747,:777; tests inside a'blur-or-enter'FormLayout). EntryErrorBehaviornames the two values and is exported from FormLayout, DateInput, DateTimeInput and TimeInput: verified (FormLayoutContext.ts:57and the fourindex.tsfiles).- A native time control's out-of-range edit waits for Enter or blur: verified (
useTypedTime.ts:306-320,NativeTimeSegment.tsx:290-300; jsdom tests; real-browser check). - A date the native date control refuses already waits for Enter or blur under both values: verified (new
NativeDateField.test.tsxcase for both values). - DateTimeInput's time segment shares TimeInput's typed-time hook and native time control: verified (
DateTimeInput.tsx:890,TimeInput.tsx:89). - TimeInput and DateTimeInput's time segment already commit typed text on Enter by default: verified (Enter handling in
TimeInput.tsxon the base branch). - A busy TimeInput stays editable but reveals no rejection of its own until idle: verified (
TimeInput.tsx:554,:597). - NumberInput already reveals rejections only at commit: verified against NumberInput's rejected-entry record clause; this change does not touch NumberInput.
- Usage that sets neither prop is unchanged: verified (existing suites; base and head render the same after a commit).
- The interaction browser spec gains four
'blur-or-enter'cases: verified in the diff; the DateInput case reproduces in a real browser. - The listed test, typecheck, lint, format, knowledge and changeset runs pass: the description names an earlier commit; at this head the changed test files (661 tests), typecheck, lint, format, knowledge and changeset checks pass.
- 1,309 authored lines: verified.
Files
.changeset/entry-error-behavior.md: cleardocs/families/input-fields.md: cleardocs/specs/AST-117-validation-timing/spec.md: cleardocs/specs/components/DateInput/DateInput.spec.md: cleardocs/specs/components/DateTimeInput/DateTimeInput.spec.md: cleardocs/specs/components/FormLayout/FormLayout.spec.md: cleardocs/specs/components/TimeInput/TimeInput.spec.md: clearpackages/core/src/DateInput/DateInput.doc.mjs: clearpackages/core/src/DateInput/DateInput.test.tsx: clearpackages/core/src/DateInput/DateInput.tsx: clearpackages/core/src/DateInput/NativeDateField.test.tsx: clearpackages/core/src/DateInput/__tests__/DateInputRejectedEntry.interaction.browser.spec.ts: clearpackages/core/src/DateInput/index.ts: clearpackages/core/src/DateInput/useTypedDate.ts: clearpackages/core/src/DateTimeInput/DateTimeInput.doc.mjs: clearpackages/core/src/DateTimeInput/DateTimeInput.test.tsx: clearpackages/core/src/DateTimeInput/DateTimeInput.tsx: clearpackages/core/src/DateTimeInput/NativeTimeSegment.tsx: non-blocking note (no real-browser case for the new Enter and blur commit)packages/core/src/DateTimeInput/index.ts: clearpackages/core/src/Field/useEntryErrorBehavior.ts: clearpackages/core/src/FormLayout/FormLayout.doc.mjs: clearpackages/core/src/FormLayout/FormLayout.test.tsx: clearpackages/core/src/FormLayout/FormLayout.tsx: clearpackages/core/src/FormLayout/FormLayoutContext.ts: clearpackages/core/src/FormLayout/index.ts: clearpackages/core/src/PowerSearch/PowerSearchValueEditor.test.tsx: clearpackages/core/src/PowerSearch/PowerSearchValueEditor.tsx: clearpackages/core/src/Table/plugins/filtering/useTableFiltering.test.tsx: clearpackages/core/src/Table/plugins/filtering/useTableFiltering.tsx: clearpackages/core/src/TimeInput/TimeInput.doc.mjs: clearpackages/core/src/TimeInput/TimeInput.test.tsx: clearpackages/core/src/TimeInput/TimeInput.tsx: clearpackages/core/src/TimeInput/index.ts: clearpackages/core/src/TimeInput/useTypedTime.ts: clear
| onCommit(); | ||
| }, [commitValue, nativeValue, isRejected, onCommit]); | ||
|
|
||
| const handleKeyDown = useCallback( |
There was a problem hiding this comment.
Non-blocking: this Enter commit, and the blur commit at line 290, are covered only by jsdom fireEvent tests. The entry error behavior spec's platform-support section asks for a real-browser check that Enter and blur commit on native surfaces. A TimeInput presentation="native" case in the interaction browser spec (a time before min: no aria-invalid while typed, then aria-invalid and the message at Enter and at blur) would keep this path proved in Chromium and WebKit.
Stack: #11485 → #11492
User need
A form that checks its fields on blur shows nothing while a person types into a text field, but DateInput, DateTimeInput, and TimeInput flag some of their own rejections mid-typing: a date the calendar does not have (
02/31/2026) or one outsidemin/maxas soon as the typed date is complete, and a complete time outside the range. In that form, the date and time fields light up red and announce an error while the person is still typing, and every other field waits for blur. The caller cannot hold those signals back: the rejection belongs to the field, and wrapping it cannot delay itsaria-invalid, its message, or its live-region announcement. Builders need one setting that holds a field's own rejections to Enter or blur, for one field or for a whole form, without losing early feedback in forms that want it.Problem and solution fit
entryErrorBehavioron DateInput, DateTimeInput, and TimeInput chooses the moment a field reveals its own rejection:'complete'(the default, each field's shipped timing) or'blur-or-enter'.'blur-or-enter', typing reveals nothing. Enter or blur reveals the entry's current rejection with every signal at once: the message,aria-invalid, the invalid text styling, one announcement, and theonEntryErrorChangereport, so a callererrorstatus driven by that report appears at the same commit. An edit that makes the entry valid or empty clears at once. An edit that leaves it wrong keeps the shown error without announcing it again, until the next commit. A native time control's out-of-range edit waits for Enter or blur the same way.defaultEntryErrorBehavioron FormLayout sets it for a form through the layout context that already carriesdefaultOptionality. A field's own prop wins; a nested FormLayout replaces the default (unset there means'complete'); content in a layer such as a Dialog starts without it.'complete'explicitly, so a FormLayout around them does not change their timing.EntryErrorBehavioris exported from FormLayout, DateInput, DateTimeInput, and TimeInput.TimeInput is included because DateTimeInput's time segment shares TimeInput's typed-time hook and native time control; the change there is the same code path. NumberInput and Pagination's page input are left for a follow-up pull request. NumberInput already reveals every rejection only at commit, so both values behave alike there; the records keep that one gap line.
Current specification
spec:AST-117FR1–FR7, DEC-1–DEC-6 (current, approved).family:input-fieldsFR14;component:FormLayoutFR4, FR7, ORD4;component:DateInputFR24;component:DateTimeInputFR15;component:TimeInputFR13.architecture:public-component-apiINV2 (<thing>Behavior) and INV3 (the default is the shipped behavior), as AST-117 DEC-3 records.Behavior changes by clause: the reveal moment under
'blur-or-enter'(AST-117 FR4, AR1, AR2), clearing and keeping (FR5), locked fields (FR6, no change), precedence and layers (FR2), compositions (FR7). With neither prop set, nothing changes (FR3).Three AST-117 record edits for the spec owner to check, beyond closing gaps:
'blur-or-enter'"makes Enter a commit forTimeInputand forDateTimeInput's time segment, which have no Enter commit by default". Both already commit typed text on Enter under the default (AST-118 FR9). The sentence now says what the value adds there: Enter reveals a held native time rejection. The matching "FR4 gap" line is removed for the same reason.isLoadingor a pendingchangeAction) stays editable but reveals no rejection of its own until it is idle. This is the shipped AST-118 behavior and this change does not alter it; TimeInput's record lists it under Current-state impact too.Public delta and caller burden
entryErrorBehavior?: 'complete' | 'blur-or-enter'on DateInput, DateTimeInput, and TimeInput;defaultEntryErrorBehavior?: EntryErrorBehavioron FormLayout. New typeEntryErrorBehavior.FormLayoutContext's value gains an optionaldefaultEntryErrorBehavior.'complete'. Usage that sets neither is unchanged (additive,spec:AST-017FR5).validationBehavior. It never changes a callerstatus,isRequired, or form-library rules.'blur-or-enter'the announcement moves to the commit and is made once; a rejected entry kept at commit is still announced.Design and alternatives
Field/useEntryErrorBehavior(the field prop, else the FormLayout default, else'complete'), shared by the three members. The family record's Shared owner section names it.typedDateErrorinuseTypedDate(DateInput and DateTimeInput's date segment) and the fresh-rejection rule inuseTypedTime(TimeInput and DateTimeInput's time segment). Under'blur-or-enter'a complete value rejection no longer counts as revealed until a commit.useEntryErrorReportthen shows, announces, and reports exactly what the member reveals, so the status, alert, and report move together without a second copy of the timing logic. The report hook cannot gate on its own: it does not know when an entry is complete or committed.useTypedTimeas'held'and shown at a commit thatNativeTimeSegmentnow reports on Enter and blur.validationBehaviorand validation-timing names (DEC-3), separate'blur'and'enter'values (DEC-3), commit timing as the only behavior (DEC-1), and following a form default inside filter editors (DEC-5).Evidence
'complete', that a complete nonexistent date and a complete out-of-range time still show while typing.'blur-or-enter', keystroke by keystroke: no status message, noaria-invalid, no invalid style, empty alert, no announcement, and noonEntryErrorChangecall. At Enter and at blur: all of them at once, the report called once, one announcement after the live region settles.null; a still-wrong edit keeps the shown message with no new report or announcement; the next commit reveals the current rejection; a calendar pick clears it; disabled and busy fields ignore Enter and blur, and a revealed rejection shows again once editable.'blur-or-enter', stays through a still-wrong edit, and clears at once.'complete','blur-or-enter', field over form both ways, a nested layout with and without a value, a field in an inline Dialog opened in the form, and the context value itself. Type errors for other values.FormLayout defaultEntryErrorBehavior="blur-or-enter".DateInputRejectedEntry.interaction.browser.spec.tsgains four cases. In DateInput and in DateTimeInput's date segment under'blur-or-enter', typing02/31/2026key by key shows noaria-invalidand no "Enter a real date" in the control's description; Enter, and a press outside the field, then show both. With the story arg set to'complete'instead, all four fail at the last keystroke, so the arg reaches the component.'complete'while it waits.'complete'). 25 fail a test. The survivor removes the valid-or-empty test from the kept-text condition inuseTypedDate; it is equivalent, because the shown rejection already drops kept text for a valid or empty entry, and the existing report sync sendsnullright after that render.Scope
Components: DateInput, DateTimeInput, TimeInput, FormLayout, Field (internal hook), PowerSearch (value editors), Table (filter editors)
Testing
Node 24.22.1, pnpm 11.10.0. Head
b1b9a2a364on8e4cc9efa8; every run below is at that head except the mutation run: its first 25 mutations ran on the same change before the last review fixes (records, JSDoc, the held-edit switch) and a rebase that adds two CLI-only commits, and the 26th ran on the final code.Not run locally: the WebKit project of the interaction suite (the Linux host lacks WebKit's system libraries); CI runs it. Screen-reader passes for AR1–AR3 (
spec:AST-009) are not part of this change; the live-region assertions above cover what jsdom and Chromium can observe.Writing rubric results
Records touched:
spec:AST-117,family:input-fields,component:DateInput,component:DateTimeInput,component:TimeInput,component:FormLayout.source and testsorcontext source and tests. Each "TBD (gap)" verification row now names its suites and test names.Rejected:items.#plus digits,/pull/,/issues/in the changed lines).TimeInput… stays editable but reveals no rejection of its own until it is idle", in the required gap form. The "no member acceptsentryErrorBehavior" gap lines in the four component records and the family record are removed or narrowed to the one observable gap left ("FR1, FR2 gap:NumberInputtakes noentryErrorBehaviorand reads noFormLayoutdefault"). The AST-117 "FR4 gap" on Enter in TimeInput and DateTimeInput's time segment is removed because both commit on Enter today. Public-concept stability moves from "Proposed" to "Stable" in the four component records, and the family concept row from "proposed by" to "approved by".