From 3f2009071a5827b4d5327fea8ed896c8c5a990b7 Mon Sep 17 00:00:00 2001 From: userquin Date: Wed, 10 Sep 2025 21:45:23 +0200 Subject: [PATCH] chore: use fixed position for the skip link --- .../theme-default/components/VPSkipLink.vue | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/client/theme-default/components/VPSkipLink.vue b/src/client/theme-default/components/VPSkipLink.vue index 10c987e4..1ca0c457 100644 --- a/src/client/theme-default/components/VPSkipLink.vue +++ b/src/client/theme-default/components/VPSkipLink.vue @@ -17,13 +17,15 @@ function focusOnTargetAnchor({ target }: Event) { const el = targetEl?.querySelector('main h1[id][tabindex="-1"]') ?? targetEl if (el) { - const removeTabIndex = () => { - el.removeAttribute('tabindex') - el.removeEventListener('blur', removeTabIndex) - } + if (!el.hasAttribute('tabindex')) { + const removeTabIndex = () => { + el.removeAttribute('tabindex') + el.removeEventListener('blur', removeTabIndex) + } - el.setAttribute('tabindex', '-1') - el.addEventListener('blur', removeTabIndex) + el.setAttribute('tabindex', '-1') + el.addEventListener('blur', removeTabIndex) + } el.focus() window.scrollTo(0, 0) } @@ -43,6 +45,7 @@ function focusOnTargetAnchor({ target }: Event) {