Skip to content

Commit a39a97c

Browse files
committed
feat(datepicker): Keep track of latestValidTypedDate
1 parent 90f1f41 commit a39a97c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/components/Datepicker.vue

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,11 @@ export default {
250250
calendarHeight: 0,
251251
calendarSlots,
252252
isClickOutside: false,
253+
/*
254+
* The latest valid `typedDate` (used for typeable datepicker)
255+
* {Date}
256+
*/
257+
latestValidTypedDate: null,
253258
/*
254259
* Vue cannot observe changes to a Date Object so date must be stored as a timestamp
255260
* This represents the first day of the current viewing month
@@ -527,6 +532,7 @@ export default {
527532
/**
528533
* Initiate the component
529534
*/
535+
// eslint-disable-next-line complexity,max-statements
530536
init() {
531537
if (this.value) {
532538
let parsedValue = this.parseValue(this.value)
@@ -537,6 +543,8 @@ export default {
537543
this.$emit('input', parsedValue)
538544
}
539545
this.setValue(parsedValue)
546+
} else if (this.typeable) {
547+
this.latestValidTypedDate = this.utils.getNewDateObject()
540548
}
541549
542550
if (this.isInline) {
@@ -669,17 +677,23 @@ export default {
669677
this.slideDuration = parseFloat(durationInSecs) * 1000
670678
},
671679
/**
672-
* Set the datepicker value
680+
* Set the datepicker value (and, if typeable, update `latestValidTypedDate`)
673681
* @param {Date|String|Number|null} date
674682
*/
675683
setValue(date) {
676684
if (!date) {
677685
this.selectedDate = null
678686
this.setPageDate()
687+
if (this.typeable) {
688+
this.latestValidTypedDate = this.computedOpenDate
689+
}
679690
return
680691
}
681692
this.selectedDate = date
682693
this.setPageDate(date)
694+
if (this.typeable) {
695+
this.latestValidTypedDate = date
696+
}
683697
},
684698
/**
685699
* Set the picker view

0 commit comments

Comments
 (0)