Skip to content

Commit 1e5407f

Browse files
committed
fix: Remove tabindex from target after focus
1 parent 0eea882 commit 1e5407f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/VueSkipToSingle.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
</template>
1010

1111
<script>
12+
import { programmaticFocus } from './util'
13+
1214
const focusedTags = new RegExp('^(a|select|input|button|textarea)', 'i')
1315
1416
export default {
@@ -34,10 +36,8 @@ export default {
3436
if (!id) return
3537
const element = window.document.getElementById(id)
3638
if (!element) return
37-
const isFocused = focusedTags.test(element.tagName.toLowerCase())
38-
!isFocused && element.setAttribute('tabindex', -1)
39+
if (!focusedTags.test(element.tagName.toLowerCase())) return programmaticFocus(element)
3940
element.focus()
40-
!isFocused && element.removeAttribute('tabindex')
4141
}
4242
}
4343
}

0 commit comments

Comments
 (0)