diff --git a/packages/vuetify/src/components/VDatePicker/VDatePicker.tsx b/packages/vuetify/src/components/VDatePicker/VDatePicker.tsx index 3a67c042106..78d7eae311e 100644 --- a/packages/vuetify/src/components/VDatePicker/VDatePicker.tsx +++ b/packages/vuetify/src/components/VDatePicker/VDatePicker.tsx @@ -182,7 +182,9 @@ export const VDatePicker = genericComponent { + function onUpdateMonth (value: number) { if (viewMode.value === 'months') onClickMonth() - emit('update:month', month.value) - }) + emit('update:month', value) + } - watch(year, () => { + function onUpdateYear (value: number) { if (viewMode.value === 'year') onClickYear() - emit('update:year', year.value) - }) + emit('update:year', value) + } watch(model, (val, oldVal) => { const before = adapter.date(wrapInArray(val)[0]) @@ -294,6 +298,7 @@ export const VDatePicker = genericComponent @@ -302,6 +307,7 @@ export const VDatePicker = genericComponent @@ -312,6 +318,8 @@ export const VDatePicker = genericComponent diff --git a/packages/vuetify/src/components/VDatePicker/VDatePickerMonths.tsx b/packages/vuetify/src/components/VDatePicker/VDatePickerMonths.tsx index bd7099dfda5..1883a31f254 100644 --- a/packages/vuetify/src/components/VDatePicker/VDatePickerMonths.tsx +++ b/packages/vuetify/src/components/VDatePicker/VDatePickerMonths.tsx @@ -41,7 +41,7 @@ export const VDatePickerMonths = genericComponent()({ 'update:modelValue': (date: any) => true, }, - setup (props, { slots }) { + setup (props, { emit, slots }) { const adapter = useDate() const model = useProxiedModel(props, 'modelValue') @@ -82,6 +82,10 @@ export const VDatePickerMonths = genericComponent()({ } as const function onClick (i: number) { + if (model.value === i) { + emit('update:modelValue', model.value) + return + } model.value = i } @@ -93,7 +97,6 @@ export const VDatePickerMonths = genericComponent()({ onClick(i) } /> ) })} diff --git a/packages/vuetify/src/components/VDatePicker/VDatePickerYears.tsx b/packages/vuetify/src/components/VDatePicker/VDatePickerYears.tsx index 662fcbcaf3e..d596f29ab92 100644 --- a/packages/vuetify/src/components/VDatePicker/VDatePickerYears.tsx +++ b/packages/vuetify/src/components/VDatePicker/VDatePickerYears.tsx @@ -51,7 +51,7 @@ export const VDatePickerYears = genericComponent()({ 'update:modelValue': (year: number) => true, }, - setup (props, { slots }) { + setup (props, { emit, slots }) { const adapter = useDate() const model = useProxiedModel(props, 'modelValue') const years = computed(() => { @@ -109,7 +109,13 @@ export const VDatePickerYears = genericComponent()({ rounded: true, text: year.text, variant: model.value === year.value ? 'flat' : 'text', - onClick: () => model.value = year.value, + onClick: () => { + if (model.value === year.value) { + emit('update:modelValue', model.value) + return + } + model.value = year.value + }, } as const return slots.year?.({