From 08bab080b1948af1d51107ac0aad7920828b892d Mon Sep 17 00:00:00 2001 From: Jonathon Wright Date: Mon, 29 Jun 2026 19:54:30 +1000 Subject: [PATCH] nav: stop tabs sticking lit on Projects/Blog pages On pages with no scroll-spy sections, activeIdx stays -1 and indexOf(link) is also -1, so the pointerleave 'keep lit if active' check matched every hovered tab. Guard with activeIdx >= 0 so a hovered tab always retracts when nothing is active. --- src/scripts/anim.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/scripts/anim.ts b/src/scripts/anim.ts index 557ce5a..ea96503 100644 --- a/src/scripts/anim.ts +++ b/src/scripts/anim.ts @@ -118,8 +118,12 @@ function initNav(): void { for (const a of links) { a.addEventListener("pointerenter", () => under(a, true)); + // On leave, keep the underline only if this link IS the active scroll-spy + // section. Guard on activeIdx >= 0 so that when nothing is active — e.g. the + // Projects/Blog pages, where none of these sections exist and activeIdx stays + // -1 — a hovered tab doesn't stick lit via the -1 === indexOf(non-member) -1. a.addEventListener("pointerleave", () => - under(a, sectioned.indexOf(a) === activeIdx), + under(a, activeIdx >= 0 && sectioned.indexOf(a) === activeIdx), ); }