react-datepicker icon indicating copy to clipboard operation
react-datepicker copied to clipboard

Typed input sets the year back to 2001

Open bholben opened this issue 3 years ago • 4 comments

Describe the bug When typing, the year flips from current year to 2001.

To Reproduce On Chrome (MacOS)... From the React DatePicker Examples page in the uppermost Default picker, if the current date is Jan-Aug (a single digit month) and we overwrite and type in "9/1", the year will flip from the current year to 2001.

Expected behavior Because today is in 2022, I expect the year to stay as 2022 when I type "9/1".

Issue seen in Chrome on MacOS. Unable to reproduce on Safari and Firefox.

bholben avatar May 10 '22 15:05 bholben

Maybe related to https://github.com/Hacker0x01/react-datepicker/issues/3244?

bholben avatar May 10 '22 15:05 bholben

I suspect it could be the line below causing this behavior

https://github.com/Hacker0x01/react-datepicker/blob/a3596272736e671cfec13e5b73b76186b387fe77/src/date_utils.js#L124

It seems like the value is passed to new Date in some cases and a construct such as new Date("feb 2") would be a February in 2001 (probably feb 2, 2001) on Chrome. At least that's what my test show.

theill avatar Jul 01 '23 22:07 theill

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 10 days.

github-actions[bot] avatar Jun 17 '24 01:06 github-actions[bot]

Is there a good workaround that takes different date formats into account?

kmsomebody avatar Feb 08 '25 23:02 kmsomebody

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 10 days.

github-actions[bot] avatar Nov 02 '25 02:11 github-actions[bot]

This issue was closed because it has been stalled for 10 days with no activity.

github-actions[bot] avatar Nov 14 '25 02:11 github-actions[bot]