From 3e29a9b847f42cff9319bc3efb7db2de07b26dfb Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Sat, 13 Sep 2025 15:46:15 +0530 Subject: [PATCH] preserve existing tabindex if any, likely will be null unless the element is disabled/hidden and has tabindex defined by the user --- src/client/app/router.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/client/app/router.ts b/src/client/app/router.ts index 423b9d22..83ad18f3 100644 --- a/src/client/app/router.ts +++ b/src/client/app/router.ts @@ -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 } )