cloudscape-design / components

React components for Cloudscape Design System
https://cloudscape.design/
Apache License 2.0
2.34k stars 152 forks source link

[Bug]: Date picker value format is different with show format #2384

Closed n1203 closed 3 months ago

n1203 commented 3 months ago

Browser

Chrome

Package version

3.0.662

React version

18.2.0

Description

if you set value format type to YYYY/MM/DD that let app crash.

You can read this pic:

image

some error like:

image

Source code

const [date, setDate] = React.useState(dayjs(value).format("YYYY/MM/DD"));
<DatePicker
    value={date}
    onChange={(e) => setDate(e.detail.value)}
/>

Reproduction

when you set value with format YYYY/MM/DD, then you can get this error.

when you set value with format YYYY-MM-DD, then no error.

image

Code of Conduct

paivanmilovac commented 3 months ago

Same issue here.

avinashbot commented 3 months ago

Hi!

This is working as documented. The internal data format of the date picker is the standard ISO8601 date format (YYYY-MM-DD). In the props or event handlers, you should provide and expect this format. The slash ("/") format is just the format presented to end users, but this is unrelated to the way you should be handling the date string on your end.