-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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
[Bug Report][3.6.4] v-date-input - localised format support #19803
Comments
It looks like it's parsing date from text field using 'en' locale, not currently selected one. |
@admg exactly. The real problem is in this place:
The I see two ways of fixing it:
For now, I can recommend a workaround for the issue, which requires to override the Side notes:
import DateFnsAdapter from '@date-io/date-fns';
import { isValid as dateFnsIsValid } from 'date-fns';
class BetterDateFnsAdapter extends DateFnsAdapter {
date(value) {
if (typeof value === "undefined") return new Date();
if (value === null) return null;
const defaultParsedValue = super.date(value);
if (dateFnsIsValid(defaultParsedValue)) return defaultParsedValue;
try {
let parseResult = this.parse(value, this.formats.keyboardDateTime24h);
if (dateFnsIsValid(parseResult)) return parseResult;
parseResult = this.parse(value, this.formats.keyboardDateTime);
if (dateFnsIsValid(parseResult)) return parseResult;
parseResult = this.parse(value, this.formats.keyboardDate);
if (dateFnsIsValid(parseResult)) return parseResult;
} catch {
// ignore
}
return defaultParsedValue;
}
}
// use the custom adapter implementation
const vuetify = createVuetify({
date: { adapter: BetterDateFnsAdapter },
}); @johnleider , @KaelWD - what are your thoughts on this topic? |
Ohh wow I didn't know that vuetify is using date-io. Need to dive deep into this issue |
We don't use date-io. We're following the interface. |
Oh, indeed. I must have understood it wrong previously. Vuetify is using built-in adapter, but it is allowed to override it by the end users using the configuration as described in docs - https://vuetifyjs.com/en/features/dates/#adapter But the issue still remains - VDateInput is not locale aware, so something should be done to fix it. Either update the implementation of the built-in adapter, or simply inside the component improve the handling of input values to be locale aware. In case, when the changes will be done in the built-in adapter, then there may be problems, when end users are using other adapters (like DateFnsAdapter), where that changes are not implemented. Maybe it will be easier to just update the VDateInput implementation, and not touch the adapters at all? |
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. |
Refactored date adapter to make the Intl format options available for custom functions resolves vuetifyjs#19803 resolved vuetifyjs#19951
Did you guys build a date picker that's not locale aware? Is Vuetify only for the US market? 🤦♂️ |
Are we not allowed to have bugs? |
Yes very true. It would be very helpful if this could be resolved, thank you. Apologies for the snarky comment, bad day in the office! |
@johnleider Do you have any updates on this topic? |
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. |
Environment
Vuetify Version: 3.6.4
Vue Version: 3.4.21
Browsers: Chrome 125.0.0.0
OS: Windows 10
Steps to reproduce
v-date-input
Ok
v-date-input
with selected dateEnter
Expected Behavior
Pressing 'Enter' will not change the day to month or vice versa.
Actual Behavior
Enter
will 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
https://play.vuetifyjs.com/#...
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)
The text was updated successfully, but these errors were encountered: