-
-
Notifications
You must be signed in to change notification settings - Fork 198
issue with leap year while typing #659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days. |
This issue was closed because it has been stalled for 14 days with no activity. |
This is still an issue in version |
dagjomar
pushed a commit
to dagjomar/react-date-picker
that referenced
this issue
Apr 25, 2025
Fixes: wojtekmaj#659 There is an issue when trying to input a date such as "29 / 02 / 2024" (February 29th 2024) which is a leap year and should be valid. The validation runs into a state where the input fields are first rendered with the inputs day: 29 month: 2 year: 202 which is not a leap year, and thus the day 29 is not valid for this state. The problem occurs when running the onChangeExternal, which tries to read the validity state of the dayInput react Ref. However, that ref has last been rendered with a min/max number value calculated from the previous month and year (month 2 and year 202). Therefore the day input field still believes that the day 29 is not valid, even though we have just entered 2024 into the year field. This workaround is to just use a new instance of a DOM input field that emulates what the real input field should do, and check this validity value instead, which will be correct using the current updated values. The real input field values will become valid next render cycle. Ironic to make another "shadow DOM" inside react, but at least it works. Added a bunch of unit tests for this case, and improved the test coverage of utility methods as well
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Before you start - checklist
Description
Hi,
I have set the date format on my date picker as MM/dd/yyyy.
However, when the user writes a date in the input, for example 02/29/200 , the date picker value becomes 03/01/200 , so it looks like the date format is still the original for the user input.
Has anyone had this issue before and knows a solution?
Steps to reproduce
change the format to MM/dd/yyyy
type 02/29/200
it will change to 03/01/200
Expected behavior
till needs to wait to add complete year
Actual behavior
changing the date to next day
Additional information
No response
Environment
The text was updated successfully, but these errors were encountered: