fix(theme): skip link jumps to aside instead main content heading/anchor

userquin/fix-skip-to-content
userquin 1 week ago
parent fe26488bbc
commit f773917332

@ -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<HTMLAnchorElement>('main h1[id][tabindex="-1"]') ?? targetEl
if (el) {
const removeTabIndex = () => {
el.removeAttribute('tabindex')

Loading…
Cancel
Save