early return in second case

pull/4943/head
Divyansh Singh 1 week ago
parent da2a99c717
commit 38e94ac58a

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

Loading…
Cancel
Save