From f7269fe1d1b1c3a75a44f978e202ca2f01c06c6f Mon Sep 17 00:00:00 2001 From: Huong Nguyen Date: Tue, 25 Jun 2024 11:03:42 +0100 Subject: [PATCH] try navigate to href manually Signed-off-by: Huong Nguyen --- .../theme/kedro-sphinx-theme/layout.html | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/kedro_sphinx_theme/theme/kedro-sphinx-theme/layout.html b/src/kedro_sphinx_theme/theme/kedro-sphinx-theme/layout.html index 7ae2524..a70c9f2 100644 --- a/src/kedro_sphinx_theme/theme/kedro-sphinx-theme/layout.html +++ b/src/kedro_sphinx_theme/theme/kedro-sphinx-theme/layout.html @@ -72,13 +72,20 @@ // Select all navigation links within the .wy-main-nav container var navLinks = document.querySelectorAll('.wy-main-nav .wy-main-nav-link'); - // Iterate over each link navLinks.forEach(function(link) { - // Check if the link's href matches the current URL - if (link.href === currentUrl) { - // Add the 'active' class to the matching link - link.classList.add('active'); - } + link.addEventListener('click', function(event) { + // Prevent the default link action + event.preventDefault(); + + // Remove 'active' class from all links + removeActiveClass(); + + // Add 'active' class to the clicked link + event.target.classList.add('active'); + + // Manually navigate to the link's href + window.location.href = event.target.getAttribute('href'); + }); }); });