6
6
role =" tab"
7
7
:aria-selected =" isActive"
8
8
:aria-disabled =" $props.disabled || parentDisabled"
9
- :href =" hrefComputed"
10
- :target =" target"
11
- :to =" to"
12
- :replace =" replace"
13
- :exact =" exact"
14
- :active-class =" activeClass"
15
- :exact-active-class =" exactActiveClass"
16
9
:class =" classComputed"
17
10
:style =" computedStyle"
18
11
@mouseenter =" updateHoverState(true)"
19
12
@mouseleave =" updateHoverState(false)"
13
+ @focus =" onFocus"
14
+ @click =" onTabClick"
15
+ @keydown.enter =" onTabKeydown"
16
+ :tabindex =" tabIndexComputed"
17
+ v-on =" keyboardFocusListeners"
18
+ v-bind =" linkAttributesComputed"
20
19
>
21
20
<div
22
21
class =" va-tab__content"
23
- :tabindex =" tabIndexComputed"
24
- @focus =" onFocus"
25
- @click =" onTabClick"
26
- @keydown.enter =" onTabKeydown"
27
- v-on =" keyboardFocusListeners"
28
22
>
29
23
<slot >
30
24
<va-icon
43
37
</template >
44
38
45
39
<script lang="ts" setup>
46
- import { computed , inject , onBeforeUnmount , onMounted , ref , shallowRef } from ' vue'
40
+ import { computed , inject , nextTick , onBeforeUnmount , onMounted , ref , shallowRef } from ' vue'
47
41
48
42
import {
49
43
useComponentPresetProp ,
@@ -85,7 +79,7 @@ const leftSidePosition = ref(0)
85
79
86
80
const { keyboardFocusListeners, hasKeyboardFocus } = useKeyboardOnlyFocus ()
87
81
88
- const { tagComputed, hrefComputed, isActiveRouterLink } = useRouterLink (props )
82
+ const { tagComputed, isActiveRouterLink, linkAttributesComputed } = useRouterLink (props )
89
83
const classComputed = computed (() => ({ ' va-tab--disabled' : props .disabled }))
90
84
const {
91
85
parentDisabled,
@@ -122,12 +116,14 @@ const updateSidePositions = () => {
122
116
leftSidePosition .value = componentOffsetLeft
123
117
}
124
118
125
- const onTabClick = () => {
119
+ const onTabClick = async () => {
120
+ await nextTick ()
126
121
selectTab (tabComponent )
127
122
emit (' click' )
128
123
}
129
124
130
- const onTabKeydown = () => {
125
+ const onTabKeydown = async () => {
126
+ await nextTick ()
131
127
selectTab (tabComponent )
132
128
emit (' keydown-enter' )
133
129
}
@@ -180,6 +176,8 @@ onBeforeUnmount(() => {
180
176
vertical-align : var (--va-tab-vertical-align );
181
177
color : var (--va-tab-color );
182
178
179
+ @include keyboard-focus-outline ($radius : 2px , $offset : -2px );
180
+
183
181
& __content {
184
182
align-items : var (--va-tab-content-align-items );
185
183
color : var (--va-tab-content-color );
@@ -194,8 +192,6 @@ onBeforeUnmount(() => {
194
192
white-space : var (--va-tab-content-white-space );
195
193
padding : var (--va-tab-content-padding );
196
194
cursor : var (--va-tab-content-cursor );
197
-
198
- @include keyboard-focus-outline ($radius : 2px , $offset : -2px );
199
195
}
200
196
201
197
& __icon {
0 commit comments