nav: stop tabs sticking lit on Projects/Blog pages
build-and-deploy / build (push) Failing after 14m26s
build-and-deploy / build (push) Failing after 14m26s
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.
This commit is contained in:
+5
-1
@@ -118,8 +118,12 @@ function initNav(): void {
|
|||||||
|
|
||||||
for (const a of links) {
|
for (const a of links) {
|
||||||
a.addEventListener("pointerenter", () => under(a, true));
|
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", () =>
|
a.addEventListener("pointerleave", () =>
|
||||||
under(a, sectioned.indexOf(a) === activeIdx),
|
under(a, activeIdx >= 0 && sectioned.indexOf(a) === activeIdx),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user