|
|
@ -10,10 +10,12 @@ const backToTop = ref()
|
|
|
|
watch(() => route.path, () => backToTop.value.focus())
|
|
|
|
watch(() => route.path, () => backToTop.value.focus())
|
|
|
|
|
|
|
|
|
|
|
|
function focusOnTargetAnchor({ target }: Event) {
|
|
|
|
function focusOnTargetAnchor({ target }: Event) {
|
|
|
|
const el = document.getElementById(
|
|
|
|
const targetEl = document.getElementById(
|
|
|
|
decodeURIComponent((target as HTMLAnchorElement).hash).slice(1)
|
|
|
|
decodeURIComponent((target as HTMLAnchorElement).hash).slice(1)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const el = targetEl?.querySelector<HTMLAnchorElement>('main h1[id][tabindex="-1"]') ?? targetEl
|
|
|
|
|
|
|
|
|
|
|
|
if (el) {
|
|
|
|
if (el) {
|
|
|
|
const removeTabIndex = () => {
|
|
|
|
const removeTabIndex = () => {
|
|
|
|
el.removeAttribute('tabindex')
|
|
|
|
el.removeAttribute('tabindex')
|
|
|
|