@@ -8,8 +8,11 @@ import { VBtn } from '@/components/VBtn'
8
8
import { useDate } from '@/composables/date'
9
9
import { useProxiedModel } from '@/composables/proxiedModel'
10
10
11
+ // Directives
12
+ import vIntersect from '@/directives/intersect'
13
+
11
14
// Utilities
12
- import { computed , nextTick , onMounted , watchEffect } from 'vue'
15
+ import { computed , watchEffect } from 'vue'
13
16
import { convertToUnit , createRange , genericComponent , propsFactory , templateRef , useRender } from '@/util'
14
17
15
18
// Types
@@ -48,6 +51,8 @@ export const VDatePickerYears = genericComponent<VDatePickerYearsSlots>()({
48
51
49
52
props : makeVDatePickerYearsProps ( ) ,
50
53
54
+ directives : { vIntersect } ,
55
+
51
56
emits : {
52
57
'update:modelValue' : ( year : number ) => true ,
53
58
} ,
@@ -91,10 +96,10 @@ export const VDatePickerYears = genericComponent<VDatePickerYearsSlots>()({
91
96
92
97
const yearRef = templateRef ( )
93
98
94
- onMounted ( async ( ) => {
95
- await nextTick ( )
99
+ function focusSelectedYear ( ) {
96
100
yearRef . el ?. focus ( )
97
- } )
101
+ yearRef . el ?. scrollIntoView ( { block : 'center' } )
102
+ }
98
103
99
104
function isYearAllowed ( year : number ) {
100
105
if ( Array . isArray ( props . allowedYears ) && props . allowedYears . length ) {
@@ -111,6 +116,9 @@ export const VDatePickerYears = genericComponent<VDatePickerYearsSlots>()({
111
116
useRender ( ( ) => (
112
117
< div
113
118
class = "v-date-picker-years"
119
+ v-intersect = { [ {
120
+ handler : focusSelectedYear ,
121
+ } , null , [ 'once' ] ] }
114
122
style = { {
115
123
height : convertToUnit ( props . height ) ,
116
124
} }
0 commit comments