diff --git a/src/client/theme-default/components/VPSkipLink.vue b/src/client/theme-default/components/VPSkipLink.vue index ad56622d..10c987e4 100644 --- a/src/client/theme-default/components/VPSkipLink.vue +++ b/src/client/theme-default/components/VPSkipLink.vue @@ -10,10 +10,12 @@ const backToTop = ref() watch(() => route.path, () => backToTop.value.focus()) function focusOnTargetAnchor({ target }: Event) { - const el = document.getElementById( + const targetEl = document.getElementById( decodeURIComponent((target as HTMLAnchorElement).hash).slice(1) ) + const el = targetEl?.querySelector('main h1[id][tabindex="-1"]') ?? targetEl + if (el) { const removeTabIndex = () => { el.removeAttribute('tabindex')