-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[TimePicker] AdapterDayjs fails to validate input when using with TimePicker
#6984
Comments
TimePicker
TimePicker
TimePicker
I'm having the same problem, but for date validation. For example, if I put the date as 15/60/2021 (DD/MM/YYYY format), dayjs sums up the months that exceeded 12 and creates a new date, in this case 10/15/2025. The same thing should probably happen with the hours in your case. I'm still looking for a solution... |
Hi no not yet, waiting for the adapter fix |
I think the problem is that if the date is incorrect, as I mentioned earlier, dayjs does the sum and ends up validating the date in its date object. But you can use dayjs().$d to use the date in the javascript date format, in this |
You can use: const date = dayjs(date_as_string, date_format, true).$d the last prop is |
great thanks for the suggestion, I'll give it a try |
@RCout1nho Thanks for the suggestion, I'm struggling with this too. Would you know if they have removed the "Invalid time format" validation message too? I can't seem to trigger it and none of the examples seem to display it. |
You can use the onError prop like this: onError={(reason, value)=>{}} reason prop can be: 'minDate' | 'maxDate' | 'invalidDate' | 'shouldDisableDate' | 'disablePast' | null |
TimePicker
TimePicker
The last version of the library no longer has the bug see this reproduction case |
Duplicates
Latest version
Current behavior 😯
When using dayjs-adapter, with time picker, when a user changes an existing time to something invalid (ie 99:99) the input does not enter an error state. Tested with '@mui/lab/AdapterDateFns" and '@mui/lab/AdapterMoment' and the input goes into error state as expected.
here is the the sandbox:
https://codesandbox.io/s/basictimepicker-material-demo-forked-mk19f?file=/public/index.html
Left: AdapterDateFns / Right: AdapterDayjs

Expected behavior 🤔
adapter should handle invalid times
Steps to reproduce 🕹
Steps:
https://codesandbox.io/s/basictimepicker-material-demo-forked-mk19f?file=/public/index.html
Context 🔦
No response
Your environment 🌎
`npx @mui/envinfo`
The text was updated successfully, but these errors were encountered: