From 6497d6a2168e9b80b18c3cc333d1248aeaa0e0f9 Mon Sep 17 00:00:00 2001 From: Sanajit Jana Date: Fri, 26 Sep 2025 12:37:07 +0530 Subject: [PATCH] fix: underlines the wrong section title Signed-off-by: Sanajit Jana --- .../docs/[topic]/[...path]/OnThisPage.svelte | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/svelte.dev/src/routes/docs/[topic]/[...path]/OnThisPage.svelte b/apps/svelte.dev/src/routes/docs/[topic]/[...path]/OnThisPage.svelte index 3bad6b262c..5432064af4 100644 --- a/apps/svelte.dev/src/routes/docs/[topic]/[...path]/OnThisPage.svelte +++ b/apps/svelte.dev/src/routes/docs/[topic]/[...path]/OnThisPage.svelte @@ -10,12 +10,19 @@ afterNavigate(() => { current = location.hash.slice(1); headings = content.querySelectorAll('h2'); - update(); // Ensure active link is set correctly on navigation + setTimeout(() => update(), 0); // Delay to allow layout to settle }); // Update function to activate the correct section link function update() { const threshold = (innerHeight * 1) / 3; + + // If scrolled less than threshold, activate the page title + if (scrollY < threshold) { + current = ''; + return; + } + let found = false; for (let i = 0; i < headings.length; i++) { @@ -33,10 +40,7 @@ } } - // Handle case when scrolled to the top of the page - if (!found && scrollY === 0) { - current = ''; - } + // If no heading found, keep current as is }