From faa26d58bf0cb42530b6a778b4fae6d27e0cb35f Mon Sep 17 00:00:00 2001 From: Norman Walsh Date: Tue, 30 Jan 2024 18:11:00 +0000 Subject: [PATCH] Try a little harder to scroll the ptoc into view --- src/main/web/js/persistent-toc.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/web/js/persistent-toc.js b/src/main/web/js/persistent-toc.js index 9cf2ee10dd..5b1badf7ef 100644 --- a/src/main/web/js/persistent-toc.js +++ b/src/main/web/js/persistent-toc.js @@ -134,12 +134,26 @@ + window.location.hash); } - let path = window.location.pathname.substring(1) + window.location.hash; + // Try path#hash + let path = url.substring(1) + hash; let target = document.querySelector("nav.toc div a[rel-path='"+path+"']"); if (target) { target.scrollIntoView(); } else { - console.log(`ToC scroll, no match: ${path}`); + // Try #hash + target = document.querySelector("nav.toc div a[rel-path='"+hash+"']"); + if (target) { + target.scrollIntoView(); + } else { + // Try path + target = document.querySelector("nav.toc div a[rel-path='"+url.substring(1)+"']"); + if (target) { + target.scrollIntoView(); + } else { + // ??? + console.log(`ToC scroll, no match: ${path}`); + } + } } if (!searchListener) {