Skip to content

Commit 5164c3f

Browse files
committed
Fix year/month select on the datepicker
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
1 parent eea76b6 commit 5164c3f

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

src/components/DatetimePicker/DatetimePicker.vue

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,24 @@ export default {
7676
7777
methods: {
7878
handleSelectYear(year) {
79-
if (this.value) {
79+
const value = this.$refs.datepicker.currentValue
80+
if (value) {
8081
try {
81-
const value = new Date(new Date(this.value).setFullYear(year))
82-
this.$refs.datepicker.selectDate(value)
82+
const date = new Date(new Date(value).setFullYear(year))
83+
this.$refs.datepicker.selectDate(date)
8384
} catch (error) {
84-
console.error('Invalid value', this.value, year)
85+
console.error('Invalid value', value, year)
8586
}
8687
}
8788
},
8889
handleSelectMonth(month) {
89-
if (this.value) {
90+
const value = this.$refs.datepicker.currentValue
91+
if (value) {
9092
try {
91-
const value = new Date(new Date(this.value).setMonth(month))
92-
this.$refs.datepicker.selectDate(value)
93+
const date = new Date(new Date(value).setMonth(month))
94+
this.$refs.datepicker.selectDate(date)
9395
} catch (error) {
94-
console.error('Invalid value', this.value, month)
96+
console.error('Invalid value', value, month)
9597
}
9698
}
9799
}

0 commit comments

Comments
 (0)