early return in second case

pull/4943/head
Divyansh Singh 7 days ago
parent da2a99c717
commit 38e94ac58a

@ -289,15 +289,14 @@ export function scrollTo(hash: string, smooth = false, scrollPosition = 0) {
target.focus({ preventScroll: true })
if (document.activeElement === target) return
// target is not focusable, make it temporarily focusable
const tabindex = target.getAttribute('tabindex')
target.setAttribute('tabindex', '-1')
if (target.hasAttribute('tabindex')) return
const restoreTabindex = () => {
if (tabindex == null) target.removeAttribute('tabindex')
else target.setAttribute('tabindex', tabindex)
target.removeAttribute('tabindex')
target.removeEventListener('blur', restoreTabindex)
}
target.setAttribute('tabindex', '-1')
target.addEventListener('blur', restoreTabindex)
target.focus({ preventScroll: true })

Loading…
Cancel
Save