date-fns DatePicker format bug when typing in the date input
See original GitHub issue- I have searched the issues of this repository and believe that this is not a duplicate.
Reproduction link
Steps to reproduce
- Type
01/01/2021
in the date input 01/01/0002021
is entered instead
What is expected?
01/01/2021
should be entered in the date input
What is actually happening?
01/01/0002021
is entered is the date input
Environment | Info |
---|---|
antd | 4.15.1 |
React | 17.0.1 |
System | macOS Big Sur 11.2.3 |
Browser | Chrome 89.0.4389.114 |
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
DatePicker has weird behavior with manual typing using date ...
DatePicker has weird behavior with manual typing using date-fns #5221 ... The cursor is moving around like going at the end of the...
Read more >Material UI DatePicker Showing Wrong Date - Stack Overflow
I've faced the same problem. After all, I added a parseISO method on my date, you need to specify the timezone of the...
Read more >Datepicker - Angular Material
The datepicker allows users to enter a date either through text input, or by choosing a date from the calendar. It is made...
Read more >How to use the date-fns.isValid function in date-fns - Snyk
To help you get started, we've selected a few date-fns.isValid examples, based on popular ways it is used in public projects.
Read more >DatePicker Lightning Web Component ReadMe
error. string. Adds text for an error message. name. string. Adds a name for the date picker. mask. To define how a user...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Actually, I just found a simple workaround that stops leading zeroes being added when typing year.
Instead of using the
yyyy
pattern,just using
y
will do the trick@appleshell Thanks for pointing out the reason mate.
But replacing
date-fns
withmoment
ordayjs
doesn’t really solve this problem (it’s just a workaround), and I believe most people who switched frommoment
todate-fns
would prefer not to go back