-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[DatePicker] Dayjs adapter gives unexpected results for invalid date inputs #6983
Comments
I think the error is actually in the date-io/dayjs lib. Material-ui's AdapterDayJs (@mui/lab/AdapterDayJs) is just a wrapper for @date-io/dayjs. |
I finished the fix and opened a PR. While PR is not accepted, if you want, you can use temporarily this way:
|
any progress as it seems like the issue is stuck without progress for too long? Proposal from @RCout1nho works great and I am thankful. Still, I don't like to have a library file in my source code. |
The last version of the library no longer has the bug see this reproduction case |
Duplicates
Latest version
Current behavior 😯
This is the same issue as @RCout1nho in https://github.com/mui-org/material-ui/issues/29838, however I felt like this deserved its own issue because it's with the DatePicker component, not the TimePicker.
If you input an invalid date into the MUI DatePicker using the dayjs adapter, many dates are accepted as valid that shouldn't be.
For example, inputting the month as "13" and having it wrap to January of the next year seems incorrect to me.
Since MUI is doing the
dayjs
call internally, the library user cannot work around this.As mentioned in that issue using the strict arg is probably the right solution as per iamkun/dayjs#320
I am going to have to switch to using the luxon or date-fns adapter which is too bad because they are much larger libraries.
Expected behavior 🤔
MUI should provide an error message when an invalid date is input.
OR at least provide some escape hatch for the library user to get the raw user input in
onChange
so the library user can manage thedayjs
calls by hand.Steps to reproduce 🕹
Steps:
https://codesandbox.io/s/basictimepicker-material-demo-forked-1hflu
Context 🔦
I want my user to only be able to input dates that make sense.
Your environment 🌎
`npx @mui/envinfo`
Browser is chromium
The text was updated successfully, but these errors were encountered: