Skip to content

Commit

Permalink
fix: Remove tabindex from target after focus
Browse files Browse the repository at this point in the history
  • Loading branch information
ktquez committed Sep 4, 2020
1 parent 0eea882 commit 1e5407f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/VueSkipToSingle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
</template>

<script>
import { programmaticFocus } from './util'
const focusedTags = new RegExp('^(a|select|input|button|textarea)', 'i')
export default {
Expand All @@ -34,10 +36,8 @@ export default {
if (!id) return
const element = window.document.getElementById(id)
if (!element) return
const isFocused = focusedTags.test(element.tagName.toLowerCase())
!isFocused && element.setAttribute('tabindex', -1)
if (!focusedTags.test(element.tagName.toLowerCase())) return programmaticFocus(element)
element.focus()
!isFocused && element.removeAttribute('tabindex')
}
}
}
Expand Down

0 comments on commit 1e5407f

Please sign in to comment.