Skip to content

[BUG] - DatePicker (locale="th-TH") clears input and returns BC year when typing Buddhist Era years #5652

@thirddeity

Description

@thirddeity

HeroUI Version

"@heroui/react": "^2.7.8"

Describe the bug

When using the DatePicker component with locale="th-TH", typing a Buddhist Era year (e.g., 2544) causes unexpected behavior:

  • When the user starts typing the year (e.g., enters 2), the onChange event immediately fires with an incorrect value:
{
  "calendar": { "identifier": "gregory" },
  "era": "BC",
  "year": 542,
  "month": 8,
  "day": 1
}
  • At the same time, the input field is cleared, leaving only the partial year instead of the full typed value.
    This makes it impossible for users to enter Buddhist Era years correctly.

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

  1. on HeroUiProvider wrapper render <HeroUIProvider locale="th-TH">
  2. Render the component: <DatePicker onChange={(v) => console.log(v)} />
  3. Focus the input field.
  4. Type 01 → 08 → 2544.
  5. Notice that after typing the first digits of the year (2), the onChange fires with era: "BC" and the input value resets.

Expected behavior

  • The component should wait until the year is fully typed before parsing.
  • Input should not be cleared prematurely.
  • Buddhist Era years (e.g., 2544) should map correctly to Gregorian years.

Actual Behavior

  • Partial input is interpreted as BC year.
  • Input is cleared unexpectedly.
  • Users cannot type Buddhist Era years properly.

Screenshots or Videos

reproduce.mov

Operating System Version

mac OS

Browser

Chrome

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions