-
-
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
[Date Picker] DatePicker improperly adds extra 0's on Single-Digit Months and Days; It Should Strictly Respect Given Date Format #14719
Comments
Hi, The behavior around leading zeroes is explained in this doc section You can enforce it, but this comes with some tradeoffs if you try to access the value directly on the DOM element or if you are using form submission. |
Can you please explain the tradeoffs? The only reason why I thought this was a bug is because I didn't see anything about this in the migration guide.... Thank you. |
I linked you the doc section for the full context. But to summarize, if we don't have a leading zero, there are some situations where we need to add a hidden character in your input to make sure |
Ok... thank you guys. (Hopefully this is added to the migration docs). |
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Note We value your feedback @epicstar! How was your experience with our support team? |
Steps to reproduce
Link to live examples:
Steps (in live example):
DatePicker.format
to:M/D/YY
if usingdayjs
M/d/yy
if usingdate-fns
DatePicker
'sTextField
's date format to the library'sformat(date, fmt)
return string (see Demo.tsx)Current behavior
V5
Expected Behavior Happens
V7 - Bug Occurs
The
DatePicker
'sTextField
displays adds 1 extra 0 to single date months and days despite the date format specifically wanting single-digit months and days.Expected behavior
The given format to the TextField should be the same as the library's
format(date, fmt)
call. This was the case in v5 of the Date Picker library.Context
In most cases of our frontend (not all), we expected all our date formats to follow the following pattern:
We're doing this for mostly... reasons (keeps the text field compact etc.).
When updating from v5 to v7 (skipped v6), we noticed our date pickers have added zeroes to single digit days or months regardless of the given date format. The format seems to be followed as expected except for the single digit case I can't figure out a reason why the format is changed such that we are adding extra
M
's andd|D
's to the format when v5 strictly followed the given format.Your environment
npx @mui/envinfo
Search keywords: date picker format
The text was updated successfully, but these errors were encountered: