preserve existing tabindex if any, likely will be null unless the element is disabled/hidden and has tabindex defined by the user

pull/4943/head
Divyansh Singh 1 week ago
parent b3f6772df7
commit 3e29a9b847

@ -288,11 +288,13 @@ export function scrollTo(hash: string, smooth = false, scrollPosition = 0) {
if (document.activeElement === target) return
// target is not focusable, make it temporarily focusable
const tabindex = target.getAttribute('tabindex')
target.setAttribute('tabindex', '-1')
target.addEventListener(
'blur',
() => {
target.removeAttribute('tabindex')
if (tabindex !== null) target.setAttribute('tabindex', tabindex)
else target.removeAttribute('tabindex')
},
{ once: true }
)

Loading…
Cancel
Save