Closed momrak closed 2 years ago
Can you provide CodeSandbox with reproduction please?
I created a minimal reproduction repo now, and it works there, so there is something weird in my original repo it seems. Versions are all the same, and the only difference I can see is with using react-hook-form in addition in the orignal repo. I will do some more digging and get back to you if I manage to reproduce it
It works when I click and use the calendar UI, but not when I use the keyboard to enter a date. I.e. go from 21.09.2021
remove last char to 21.09.202
and then add it back again to 21.09.2021
it will still be invalid date. But if I click the date from the picker it works. If you have any clue what this could be I would be grateful
Please provide a reproduction with datepicker in code sandbox and I can debug it
Hi, I have experienced the exact same issue: When selecting a date from the picker it works fine, but not when entering the date manually. The returned date is invalid.
Here's a code sandbox with a demo of the problem: https://codesandbox.io/s/inspiring-jasper-h9pjm?file=/src/App.js
As can be seen in image 1 below I use Material UIs LocalozationProvider, giving it the
nb
-localization object, I also set input-format to beDD.MM.YYYY
(I have also tried without setting this with no luck...).Hi, I have experienced the exact same issue: When selecting a date from the picker it works fine, but not when entering the date manually. The returned date is invalid.
I noticed when using the DatePicker component that it is no good passing the object itself as locale. If you change your imports to just import "dayjs/locale/nb";
and pass in the string "nb" as locale instead, it will work as expected. Tested this in your code sandbox @eliocro as well.
Released in 2.13.2
Hi,
I try to swap out react-datepicker with material UIs date picker (https://mui.com/components/date-picker/), but I have gotten stuck on some sort of formatting issue.
I think (as usual) the problem lies with something I did, so if someone is able to spot that righ away that would be great, otherwise I'll try to setup a minimal reproduction repo.
As can be seen in image 1 below I use Material UIs LocalozationProvider, giving it the
nb
-localization object, I also set input-format to beDD.MM.YYYY
(I have also tried without setting this with no luck...).Eventhough everything seems to be correct I receive
invalid date
.If I change this to using the standard UK format
DD/MM/YYYY
it works, so there seems to be some issue with the localization. Almost as if thelocalizedFormat
-plugin is not included or something.Does anyone have a clue what this might be?
Not completely sure whether this issue belongs here, in the dayjs-repo, or in the @mui-repo, so please let me know if it should be asked somewhere else :)