From 9979028d7ed529081d26f307f28cde4b5f73b0c9 Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Tue, 17 Dec 2024 12:09:45 -0500 Subject: [PATCH] fix smooth scroll bug --- docs/assets/scripts/scroll.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/assets/scripts/scroll.js b/docs/assets/scripts/scroll.js index e0c4c27e0..8a2bbe113 100644 --- a/docs/assets/scripts/scroll.js +++ b/docs/assets/scripts/scroll.js @@ -1,13 +1,14 @@ // Smooth links document.addEventListener('click', event => { const link = event.target.closest('a'); - const id = (link?.hash ?? '').substr(1); - if (!link || link.getAttribute('data-smooth-link') === 'off') { return; } - if (id) { + const id = (link.hash ?? '').substr(1); + + // Only handle smooth scroll if there's a hash and the link points to the current page + if (id && link.pathname === window.location.pathname) { const target = document.getElementById(id); const headerHeight = document.querySelector('wa-page > header').clientHeight;