From 154e7516b89eb28f2f6c7568be92a5a28b5f572e Mon Sep 17 00:00:00 2001 From: John Leider Date: Mon, 17 Jun 2024 13:25:27 -0500 Subject: [PATCH] fix(VDatePicker): don't update month/year if new model is empty fixes #20015 --- .../vuetify/src/components/VDatePicker/VDatePicker.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/vuetify/src/components/VDatePicker/VDatePicker.tsx b/packages/vuetify/src/components/VDatePicker/VDatePicker.tsx index 55c2e0c5b72..0e6e6d98487 100644 --- a/packages/vuetify/src/components/VDatePicker/VDatePicker.tsx +++ b/packages/vuetify/src/components/VDatePicker/VDatePicker.tsx @@ -230,8 +230,13 @@ export const VDatePicker = genericComponent { - const before = adapter.date(wrapInArray(oldVal)[oldVal.length - 1]) - const after = adapter.date(wrapInArray(val)[val.length - 1]) + const arrBefore = wrapInArray(oldVal) + const arrAfter = wrapInArray(val) + + if (!arrAfter.length) return + + const before = adapter.date(arrBefore[arrBefore.length - 1]) + const after = adapter.date(arrAfter[arrAfter.length - 1]) const newMonth = adapter.getMonth(after) const newYear = adapter.getYear(after)