We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent aaa31f0 commit eea2647Copy full SHA for eea2647
src/VueSkipToSingle.vue
@@ -9,6 +9,8 @@
9
</template>
10
11
<script>
12
+const focusedTags = new RegExp('^(a|select|input|button|textarea)', 'i')
13
+
14
export default {
15
name: 'VueSkipToSingle',
16
@@ -32,10 +34,10 @@ export default {
32
34
if (!id) return
33
35
const element = window.document.getElementById(id)
36
if (!element) return
- if (!/^(a|select|input|button|textarea)/i.test(element.tagName.toLowerCase())) {
- element.setAttribute('tabindex', -1)
37
- }
+ const isFocused = focusedTags.test(element.tagName.toLowerCase())
38
+ !isFocused && element.setAttribute('tabindex', -1)
39
element.focus()
40
+ !isFocused && element.removeAttribute('tabindex')
41
}
42
43
0 commit comments