Skip to content

Commit 78339a3

Browse files
fix(VDatePicker): display proper year when model is null (#5672)
fixes #5663
1 parent 595e85c commit 78339a3

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

packages/vuetify/src/components/VDatePicker/VDatePicker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ export default {
297297
props: {
298298
date: this.value ? this.formatters.titleDate(this.value) : '',
299299
selectingYear: this.activePicker === 'YEAR',
300-
year: this.formatters.year(`${this.inputYear}`),
300+
year: this.formatters.year(this.value ? `${this.inputYear}` : this.tableDate),
301301
yearIcon: this.yearIcon,
302302
value: this.multiple ? this.value[0] : this.value
303303
},

packages/vuetify/test/unit/components/VDatePicker/VDatePicker.date.spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ test('VDatePicker.js', ({ mount, compileToFunctions }) => {
1717
expect(header.text()).toBe('November 2005')
1818
})
1919

20+
it('should display the correct year when model is null', () => {
21+
const wrapper = mount(VDatePicker, {
22+
propsData: {
23+
value: null,
24+
pickerDate: '2013-01'
25+
}
26+
})
27+
28+
const year = wrapper.find('.v-date-picker-title__year')[0]
29+
30+
expect(year.text()).toBe('2013')
31+
})
32+
2033
it('should match snapshot with default settings', () => {
2134
const wrapper = mount(VDatePicker, {
2235
propsData: {

0 commit comments

Comments
 (0)