vuetify: [Bug Report][3.6.4] v-date-input - localised format support
Environment
Vuetify Version: 3.6.4 Vue Version: 3.4.21 Browsers: Chrome 125.0.0.0 OS: Windows 10
Steps to reproduce
- Open
v-date-input - Select date - May 12th
- Click
Ok - Open
v-date-inputwith selected date - Press
Enter
Expected Behavior
Pressing ‘Enter’ will not change the day to month or vice versa.
Actual Behavior
- For dates with days equal or less than 12, pressing ‘Enter’ will toggle between day and month and vice versa.
- For dates with days greater than 12, pressing
Enterwill cause an error. As a result, the component is blocked, it’s impossible to close it by clicking ‘Cancel’ or outside the component. The page must be reloaded to ‘resolve’ the error.
Reproduction Link
Other comments
I’m also attaching one of the error stacktraces from my code, because in vuetify playground this error doesn’t appear.
TypeError: Cannot read properties of undefined (reading 'date') at default (VDatePickerMonth.tsx:170:40) at runtime-core.esm-bundler.js:4439:31 at Proxy.renderFnWithContext (runtime-core.esm-bundler.js:827:13) at Proxy.<anonymous> (runtime-core.esm-bundler.js:2171:72) at renderComponentRoot (runtime-core.esm-bundler.js:887:16) at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js:6098:26) at ReactiveEffect.run (reactivity.esm-bundler.js:177:19) at instance.update (runtime-core.esm-bundler.js:6151:16) at updateComponent (runtime-core.esm-bundler.js:5960:18) at processComponent (runtime-core.esm-bundler.js:5894:7)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 6
- Comments: 16 (6 by maintainers)
Commits related to this issue
- feat(VDateInput): parse text field value in locale aware way Refactored date adapter to make the Intl format options available for custom functions resolves #19803 resolved #19951 — committed to RafalOsieka/vuetify-date-input by RafalOsieka 2 years ago
- feat(VDateInput): add input-format prop fixes #19803 — committed to vuetifyjs/vuetify by ikushum 2 years ago
Noting that this issue is present even for other English based locales which use dd/mm/yyyy. The main desire I have is to be able to change the display format in the v-text-field.
Are we not allowed to have bugs?
I am having the same issue, and I’m hoping the locale-awareness will be implemented via the v-locale-provider, which works great with the VDatePicker.
For now, we have reverted to using the open source Duet Date Picker. Hopefully we can replace it with the modified VDateInput soon, since all of our UI components are Vuetify.
Did you guys build a date picker that’s not locale aware? Is Vuetify only for the US market? 🤦♂️
Hello everyone. Does anyone have any updates about this ? I also need to display the dates in the v-text-field with localized format and didn’t want to use new frameworks since i’m using vuetify for all of our UI.
Thank you
I tested the “display-format” property in vuetify 3.7.19 but that doesn’t solve the problem I have. I need that when I manually input the date in the v-text-field (ITALIAN FORMAT dd/MM/yyyy) this date is parsed correctly.
Right now I solved the problem in a very horrible way and I’ll explain how I did it. I have extended the VuetifyDateAdapter in this way:
To be able to do this, I also declared the module in a “.d.ts” file:
We don’t use date-io. We’re following the interface.
@admg exactly.
The real problem is in this place: https://github.com/vuetifyjs/vuetify/blob/e46a98db5be9ae899b7e31236b10de263fdd32e8/packages/vuetify/src/labs/VDateInput/VDateInput.tsx#L85
The
adapter.date(...)function is not locale aware and always tries to parse the provided value as it was a standard date string (or iso string), so in case of polish date (eg.26.05.2024), the invalid date will be returned, as it is not a valid date.I see two ways of fixing it:
date-iolibrary to make a locale aware date parsing, so consumers of that library can make use of it. Then that method can be used in vuetifyFor now, I can recommend a workaround for the issue, which requires to override the
datemethod of the adapter with custom implementation, that will check also the locale specific dates.Side notes:
datemethod is a very generic one, that is used in a lot of different places).@johnleider , @KaelWD - what are your thoughts on this topic?