-
-
Notifications
You must be signed in to change notification settings - Fork 5.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
DateInput parse and format does not display the value in the input #6315
Comments
you should avoid onBlur, this work for me |
Thanks for reporting this. I can't reproduce it on our simple example. Please provide a sample application showing the issue by forking the following CodeSandbox (https://codesandbox.io/s/github/marmelab/react-admin/tree/master/examples/simple). |
No news for some time, closing. |
Here is example of the issue being reproduced I added the parser and formatter functions from the docs to the published_at DateInput in PostCreate.tsx. The DateInput no longer shows the date that you have selected. |
The original code in the example was updated and fix over time, but the documentation wasn't changed. |
This issue is still happening, as you can see here: https://codesandbox.io/s/festive-newton-fxg5f8?file=/src/posts/PostCreate.tsx |
@cwagner22 There are two things wrong with the parse function in your codesandbox:
- if (match === null) return;
+ if (match === null) return value; and - if (isNaN(d.getDate())) return;
+ if (isNaN(d.getDate())) return value;
- const dateParseRegex = /(\d{4})-(\d{2})-(\d{2})/;
+ const dateParseRegex = /([1-2]\d{3})-(\d{2})-(\d{2})/; Remember that the parse function gets called at each character you type in the input. If you want to transform the value only at form submission, you should rather use the |
@slax57 Thank you for looking into it. However I've added your changes and it's still not working. When I type a date in the Published At input, I can see in the console logs it parses and returns a correct formatted value, but the value displayed in the input stays in the old format. |
@cwagner22 if your issue is about the display format of the date in the browser, then there is nothing we can do about it. From the MDN docs:
|
What you were expecting:
When entered manually:
DateInput
should work normally, shown in the docs's gif: https://marmelab.com/react-admin/Inputs.html#dateinput.When entered via the browser's datepicker:
DateInput
should also reflect the selected date.What happened instead:
When entered manually:
DateInput
does not let me enter the full year (inYYYY
format).dateinput-manualenter.mov
When entered via the browser's datepicker:
DateInput
shows a blank date (mm/dd/yy
, literally)dateinput-datepicker.mov
Steps to reproduce:
02 03 2021
. See that the input does not reflect what you type.mm/dd/yy
literally.Related code:
where
dateParser
anddateFormatter
is the following (straight copy-paste from the docs):Other information:
Looks like a regression in the version
3.15.2
.Visual bug because the form validation (
required()
) works just fine.Environment
The text was updated successfully, but these errors were encountered: