Skip to content

[Bug] DateInput, DateTimeInput: typing a numeric date fires onChange with month-first dates on the way #8958

Closed

Description

@duytbp

Description

Typing a numeric date into DateInput or DateTimeInput sends wrong dates to onChange on the way, and a two-digit year is read month-first whatever the locale.

parseDateInput reads a numeric date in the provider locale's order only when it has a four-digit year (dateParser.ts:111-127). Anything else that isn't bare digits falls through to new Date(trimmed) (dateParser.ts:142), which in V8 and other engines reads a/b/c as month/day/year and accepts a one- to three-digit year. The input's change handler fires onChange for every text that parses (DateInput.tsx:736-744; the same in DateTimeInput.tsx:1059-1067).

In en-GB (day first), typing 12/01/2026 one character at a time calls onChange with:

Text onChange
12/0 2001-12-01
12/01 2026-01-12
12/01/ 2001-12-01
12/01/2 2002-12-01
12/01/20 2020-12-01
12/01/202 0202-12-01
12/01/2026 2026-01-12

Only the last value is what the person typed. A caller that saves, filters or fetches on onChange acts on six wrong dates, and the open calendar jumps between December 2001, 2002, 2020 and 0202. A finished 12/01/90 commits 1990-12-01 (1 December), not 12 January 1990, in a day-first locale.

Expected: a partial numeric date (a trailing separator, or a year shorter than the locale's form) is not a date yet and fires nothing, and a two-digit year, if accepted, is read in the locale's order with a defined century rule. The native Date fallback should not read numeric input at all, since its order is fixed month-first.

Reproduction

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

export function Repro() {
  return (
    <InternationalizationProvider locale="en-GB">
      <DateInput label="Start date" onChange={value => console.log(value)} />
    </InternationalizationProvider>
  );
}
  1. Type 12/01/2026 into the field.
  2. The console logs 2001-12-01, 2026-01-12, 2001-12-01, 2002-12-01, 2020-12-01, 0202-12-01, 2026-01-12.
  3. Clear it and type 12/01/90: the last value logged is 1990-12-01.

Astryx Version

@astryxdesign/[email protected], still present on main (14fc587)

Environment

Any (V8's Date parsing); reproduced in jsdom on Node.

Activity

  1. added
    bug
    component
    on Nov 2, 2026
  2. added a commit that references this issue on Nov 5, 2026
    189a730
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

    area:corebugcomponent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions