Skip to content

Commit

Permalink
refactor(VDatePicker): reimplement fix
Browse files Browse the repository at this point in the history
  • Loading branch information
johnleider committed Apr 22, 2024
1 parent 9b8b055 commit e8efc52
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions packages/vuetify/src/components/VDatePicker/VDatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,24 +228,18 @@ export const VDatePicker = genericComponent<new <
}

watch(model, (val, oldVal) => {
const valueBefore = wrapInArray(val)[0]
const valueAfter = wrapInArray(oldVal)[0]
const before = adapter.date(valueBefore)
const after = adapter.date(valueAfter)

const monthBefore = adapter.getMonth(before)
const yearBefore = adapter.getYear(before)
const monthAfter = adapter.getMonth(after)
const yearAfter = adapter.getYear(after)

if (
valueBefore &&
(monthBefore !== monthAfter || yearBefore !== yearAfter) &&
(monthBefore !== month.value || yearBefore !== year.value)
) {
month.value = monthBefore
const before = adapter.date(wrapInArray(val)[0])
const after = adapter.date(wrapInArray(oldVal)[0])
const newMonth = adapter.getMonth(before)
const newYear = adapter.getYear(before)

if (newMonth !== month.value) {
month.value = newMonth
onUpdateMonth(month.value)
year.value = yearBefore
}

if (newYear !== year.value) {
year.value = newYear
onUpdateYear(year.value)
}

Expand Down

0 comments on commit e8efc52

Please sign in to comment.