React-date-picker: Keyboard input not correct with leading zero

Created on 19 Aug 2019  路  10Comments  路  Source: wojtekmaj/react-date-picker

When i try to enter some date with leading zero, the result is not correct.
For example:
Testing with chrome (In MM/dd/yyyy format):
When press "01012019", the result become "010/12/019". What I expect is "01/01/2019".

Testing with Edge (In yyyy-MM-dd format):
Press "2019(right key)0101", result is 2019-010-01.

By the way, when i type 0020190 in the year part, it will become blank page with error in console.
Only occur in Edge, not sure why.

You can try with the demo page:
http://projects.wojtekmaj.pl/react-date-picker/

I found you had already answered another issue which may be related to this?
https://github.com/wojtekmaj/react-date-picker/issues/156#issuecomment-515692395

Anyway, thanks for the work. It saved me from so many headache when facing the native html input type="date".

bug

Most helpful comment

Fixed in v8.1.0.

All 10 comments

Any news on this bug?

Hi,

I expose a possible solution to the extra zero problem when showLeadingZeros is being used and a zero is entered first. ( PR #241 ).

Regards

This will be fixed, but it needs https://github.com/wojtekmaj/react-date-picker/pull/272 to be merged first. For now, we rely on number inputs (from today's point of view I think that was a mistake), which don't report leading zeros in values, so we're technically unaware of them.

Hey, any updates on when this is going to get deployed?
image

:(

Any update on this bug or a workaround @wojtekmaj ?

272 is not merged yet because it's missing required input validation. I don't have a lot of free time these days. Sorry!

any updates @wojtekmaj ?

@MihaelaTIMIS Well this worked for me format="M/d/y". Now it takes only a single zero.

We solved the problem on our project by explicitly passing the date format: format='d.M.yyyy'

Fixed in v8.1.0.

Was this page helpful?
0 / 5 - 0 ratings