diff --git a/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js b/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js index 4cb168ea5..3524131bf 100644 --- a/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js +++ b/src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js @@ -101,10 +101,10 @@ function addModeListener() { function setupPageTableOfContents() { const pageToc = document.querySelector("#pst-page-toc-nav"); pageToc.addEventListener("click", (event) => { - if (!event.target.matches(".nav-link")) { + const clickedLink = event.target.closest(".nav-link") + if (!clickedLink) { return; } - const clickedLink = event.target; // First, clear all the added classes and attributes // -----