From 0657cc1848a286e416b9aed7653fc3728edd0331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= <76261501+zecakeh@users.noreply.github.com> Date: Tue, 19 Nov 2024 23:06:20 +0100 Subject: [PATCH] Fix error in ToC script at the bottom of the page (#2002) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kévin Commaille --- assets/js/toc.js | 5 +++++ changelogs/internal/newsfragments/2002.clarification | 1 + 2 files changed, 6 insertions(+) create mode 100644 changelogs/internal/newsfragments/2002.clarification diff --git a/assets/js/toc.js b/assets/js/toc.js index af8682b3..89a83ced 100644 --- a/assets/js/toc.js +++ b/assets/js/toc.js @@ -107,6 +107,11 @@ function getCurrentHeading(headings, headerOffset) { index += 1; } + // At the bottom of the page we might not have a heading. + if (!currentHeading) { + currentHeading = prevHeading; + } + return currentHeading; } diff --git a/changelogs/internal/newsfragments/2002.clarification b/changelogs/internal/newsfragments/2002.clarification new file mode 100644 index 00000000..5f641bff --- /dev/null +++ b/changelogs/internal/newsfragments/2002.clarification @@ -0,0 +1 @@ +Improve the JS script to highlight the current ToC entry.