Skip to content

Commit 186ca0f

Browse files
committed
feat(datepicker): Set correct transition on typed date
1 parent 074e359 commit 186ca0f

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

src/components/Datepicker.vue

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ export default {
252252
*/
253253
selectedDate: null,
254254
slideDuration: 250,
255-
transitionName: '',
256255
utils,
257256
view: '',
258257
}
@@ -476,7 +475,12 @@ export default {
476475
* @param {Date} date
477476
*/
478477
handleTypedDate(date) {
478+
if (this.selectedDate) {
479+
this.setTransitionAndFocusDelay(this.selectedDate, date)
480+
}
481+
479482
this.selectDate(date ? date.valueOf() : null)
483+
this.reviewFocus()
480484
},
481485
/**
482486
* Focus the relevant element when the view changes
@@ -619,19 +623,6 @@ export default {
619623
}
620624
this.pageTimestamp = this.utils.setDate(new Date(dateTemp), 1)
621625
},
622-
/**
623-
* Sets the direction of the slide transition
624-
* @param {Number} plusOrMinus Positive for the future; negative for the past
625-
*/
626-
setTransitionName(plusOrMinus) {
627-
const isInTheFuture = plusOrMinus > 0
628-
629-
if (this.isRtl) {
630-
this.transitionName = isInTheFuture ? 'slide-left' : 'slide-right'
631-
} else {
632-
this.transitionName = isInTheFuture ? 'slide-right' : 'slide-left'
633-
}
634-
},
635626
/**
636627
* Sets the slide duration in milliseconds by looking up the stylesheet
637628
*/

src/mixins/navMixin.vue

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default {
1212
navElementsFocusedIndex: 0,
1313
resetTabbableCell: false,
1414
tabbableCell: null,
15+
transitionName: '',
1516
}
1617
},
1718
computed: {
@@ -312,6 +313,19 @@ export default {
312313
pickerCells.querySelector('button.today:not(.muted):enabled') ||
313314
pickerCells.querySelector('button.cell:not(.muted):enabled')
314315
},
316+
/**
317+
* Sets the direction of the slide transition
318+
* @param {Number} plusOrMinus Positive for the future; negative for the past
319+
*/
320+
setTransitionName(plusOrMinus) {
321+
const isInTheFuture = plusOrMinus > 0
322+
323+
if (this.isRtl) {
324+
this.transitionName = isInTheFuture ? 'slide-left' : 'slide-right'
325+
} else {
326+
this.transitionName = isInTheFuture ? 'slide-right' : 'slide-left'
327+
}
328+
},
315329
/**
316330
* Tab backwards through the focus-trapped elements
317331
*/

0 commit comments

Comments
 (0)