From 118119693d8b5ac211b939775678310973bcb232 Mon Sep 17 00:00:00 2001 From: Aditya Telange <21258296+adityatelange@users.noreply.github.com> Date: Sun, 25 Oct 2026 11:53:51 +0530 Subject: [PATCH] fix(footer): move focus to anchor target so keyboard navigation continues from there --- layouts/_partials/footer.html | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/layouts/_partials/footer.html b/layouts/_partials/footer.html index 3fa4f327..218bf575 100644 --- a/layouts/_partials/footer.html +++ b/layouts/_partials/footer.html @@ -64,13 +64,20 @@ anchor.addEventListener("click", function (e) { e.preventDefault(); var id = this.getAttribute("href").substr(1); + const target = document.querySelector(`[id='${decodeURIComponent(id)}']`); if (!window.matchMedia('(prefers-reduced-motion: reduce)').matches) { - document.querySelector(`[id='${decodeURIComponent(id)}']`).scrollIntoView({ + target.scrollIntoView({ behavior: "smooth" }); } else { - document.querySelector(`[id='${decodeURIComponent(id)}']`).scrollIntoView(); + target.scrollIntoView(); } + // Move keyboard focus to the target like native anchor navigation, + // so the next Tab continues from there instead of from this link + if (target.tabIndex < 0 && !target.hasAttribute("tabindex")) { + target.setAttribute("tabindex", "-1"); + } + target.focus({ preventScroll: true }); if (id === "top") { history.replaceState(null, null, " "); } else {