Skip to content

Commit 39baaaa

Browse files
committed
early return in second case
1 parent da2a99c commit 39baaaa

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/client/app/router.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,14 @@ export function scrollTo(hash: string, smooth = false, scrollPosition = 0) {
291291

292292
// target is not focusable, make it temporarily focusable
293293
const tabindex = target.getAttribute('tabindex')
294-
target.setAttribute('tabindex', '-1')
294+
if (tabindex !== null) return // it's not focusable because of some other reason
295295

296296
const restoreTabindex = () => {
297-
if (tabindex == null) target.removeAttribute('tabindex')
298-
else target.setAttribute('tabindex', tabindex)
297+
target.removeAttribute('tabindex')
299298
target.removeEventListener('blur', restoreTabindex)
300299
}
300+
301+
target.setAttribute('tabindex', '-1')
301302
target.addEventListener('blur', restoreTabindex)
302303

303304
target.focus({ preventScroll: true })

0 commit comments

Comments
 (0)