Skip to content

Commit cc0acdf

Browse files
committed
fix(dateinput): Display initial value of typeable calendar
1 parent 0ce5cb4 commit cc0acdf

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

src/components/DateInput.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,13 @@ export default {
138138
}
139139
})
140140
},
141-
selectedDate(selectedDate) {
142-
if (this.typeable) {
143-
this.typedDate = this.formatDate(selectedDate)
144-
}
141+
selectedDate: {
142+
immediate: true,
143+
handler(selectedDate) {
144+
if (this.typeable) {
145+
this.typedDate = this.formatDate(selectedDate)
146+
}
147+
},
145148
},
146149
},
147150
mounted() {

test/unit/specs/DateInput/typedDates.spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,29 @@ describe('Datepicker mounted', () => {
258258
})
259259
})
260260

261+
describe('Datepicker mounted with a default value', () => {
262+
let wrapper
263+
264+
beforeEach(() => {
265+
wrapper = mount(Datepicker, {
266+
propsData: {
267+
typeable: true,
268+
value: new Date(new Date(2000, 0, 1).setHours(0, 0, 0, 0)),
269+
},
270+
})
271+
})
272+
273+
afterEach(() => {
274+
wrapper.destroy()
275+
})
276+
277+
it('displays a date passed in as a default value', async () => {
278+
const input = wrapper.find('input')
279+
280+
expect(input.element.value).toEqual('01 Jan 2000')
281+
})
282+
})
283+
261284
describe('Datepicker mounted with showCalendarOnFocus', () => {
262285
let wrapper
263286

0 commit comments

Comments
 (0)