Skip to content

[Bug] DateInput, DateTimeInput: a typed date's error replaces the host's status, and nothing reports why #10366

Closed

Description

@duytbp

Description

Since 0.7.9 DateInput and DateTimeInput show their own message for typed text that names a date that doesn't exist (02/31/2026) or that min, max or dateConstraints rule out, and that message replaces the host's status: useTypedDate.ts sets fieldStatus = typedStatus ?? status. The host can't word the error itself, and it can't learn why the text was refused: onChange isn't called, and nothing reports the rejection's kind. A form that words its own date errors ("Nhập ngày hợp lệ" for a date that doesn't exist, its own line for a range) can only match Astryx's translated text, which changes with the locale and the release.

Expected:

  1. A host status stays the message the field shows and announces. Astryx's typed message applies when the host passes none.
  2. A callback reports each typed rejection with a locale-independent kind (unreadable, incomplete, nonexistent, outOfRange, unavailable for a dateConstraints day) and the text, and reports its end, so the host can set that status. For example onTypedDateError?: (error: {kind, text} | null) => void.

Reproduction

import {DateInput} from '@astryxdesign/core';

export function Repro() {
  return (
    <DateInput
      label="Due"
      onChange={() => {}}
      max="2026-12-31"
      status={{type: 'error', message: 'HOST MESSAGE'}}
    />
  );
}
  1. Type 02/31/2026. The field shows "This date does not exist in the Gregorian Calendar", not "HOST MESSAGE".
  2. Type 01/05/2027. It shows "Enter a date on or before December 31, 2026".
  3. Type tomorrowish. It shows "HOST MESSAGE".

No callback fires in steps 1 and 2.

Astryx Version

@astryxdesign/[email protected] (useTypedDate.ts on main is unchanged)

Environment

Read from a jsdom test with the snippet above (the field's text and aria-invalid after each change) and from useTypedDate.ts. Browser-independent.

Activity

  1. AdhamAfis commented on Nov 7, 2026

    @AdhamAfis

    I reproduced the status override locally and have been exploring a fix for both DateInput and DateTimeInput. A prototype preserves a caller-provided status and reports typed rejections through an optional callback with a locale-independent kind and the entered text; it reports null when the rejection clears.

    The current component specification explicitly prioritizes the typed rejection over the caller's status. Would you be open to changing that contract and adding a callback like the one proposed here? In the prototype, when the caller supplies a status message, that message is announced without also announcing the built-in rejection; otherwise the existing typed-rejection announcement remains. This avoids duplicate announcements when the caller derives its message from the callback.

    The prototype passes focused component tests and a Chromium accessibility-tree check. The full suite is not green locally: a CLI global/local upgrade-notice test fails in the separate node test run.

  2. duytbp commented on Nov 8, 2026

    @duytbp
    ContributorAuthor

    A few facts that may help settle the contract and test the prototype (all on main at fb2437f and 0.7.11, where fieldStatus = typedStatus ?? status is unchanged at useTypedDate.ts:336):

    • TimeInput already lets the caller's status win. A rejected typed time sets aria-invalid and announces "Invalid time" through its own alert, but never replaces status (TimeInput.tsx#L868-L886). Reversing the precedence would make DateInput and DateTimeInput match their sibling.
    • A non-error caller status. With "any caller status wins", a field with a standing warning or success status (for example "This date is a public holiday") shows that message for 02/31/2026, and the person only sees the invalid styling. It may be worth deciding whether only an error status wins, or only a caller that passes the new callback.
    • Inside an InputGroup. A grouped DateInput renders no Field (DateInput.tsx#L1020) and passes isStatusAnnounced: !inputGroup, so a status on the DateInput itself is neither shown nor announced there. If the alert goes silent whenever a caller status is set, a grouped DateInput with its own status would announce the rejection nowhere. DateTimeInput passes isStatusAnnounced: true unconditionally.
    • Rejections that start or end without an input event. A new min, max or dateConstraints can make kept text out of range or valid again, isDisabled clears the rejection (typedDateError isn't called while disabled), and a new value or a calendar pick drops the typed text. A callback that reports only from input, Enter and blur would miss these and leave a caller's derived status stale.
    • Surfaces with no typed text. The native and touch pickers never produce a typed rejection, so the callback never fires there; the docs may want to say so.

    Downstream, we currently carry a patch on 0.7.10 that swaps the precedence to status ?? typedStatus and maps rejections to our own messages, which is the use case the callback's locale-independent kind would serve.

  3. GauravPawar101 commented on Nov 10, 2026

    @GauravPawar101

    Hey, I would like to work on this if issue out of triage or might need contributor to implement according to them.

  4. nynexman4464 commented on Nov 11, 2026

    @nynexman4464
    Contributor

    Thanks for the report and the detailed edge cases. The decision:

    • DateInput and DateTimeInput get onEntryErrorChange?: (error: {kind, text, date?} | null) => void. kind is one of unreadable, incomplete, nonexistent, outOfRange, or unavailable, and date is the Gregorian ISO date when the text names one. It fires whenever the rejection changes, including from a new min, max, or dateConstraints, disabling the field, a new value, or a calendar pick, and reports null when the rejection clears. The native and touch pickers produce no typed rejections, so it never fires there.
    • When the app passes onEntryErrorChange, an app status of type error is the message the field shows and announces, and Astryx's own message is the fallback. A warning or success status never replaces a rejection. Without the callback, the field behaves as it does today.
    • Each message is announced once. Inside an InputGroup, the field's own alert announces whichever message wins, so a rejection is never silent.

    The built-in wording also changes: a date the calendar doesn't have reads "Enter a real date", and names the calendar only when it differs from the provider's. A pull request implementing this will follow.

  5. added a commit that references this issue on Nov 12, 2026
    4705e67
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions