Fixed: navigation scroll to active link regression (#1367)

* Defer removal of href

The `href` with the URL of the current page is inspected by `navLink()`, so it should not be removed until after the calls of `navLink()` in `scrollNav()` and `activateNav()`.

As `scrollNav()` follows `activateNav()`, the removal of `href` needs to be left to `scrollNav()`.

* Update CHANGELOG.md
This commit is contained in:
Peter Mosses
2023-10-08 10:37:24 +02:00
committed by GitHub
parent 3d01bc9183
commit ae52352eae
2 changed files with 3 additions and 1 deletions

View File

@@ -497,6 +497,7 @@ function scrollNav() {
if (targetLink) {
const rect = targetLink.getBoundingClientRect();
document.getElementById('site-nav').scrollBy(0, rect.top - 3*rect.height);
targetLink.removeAttribute('href');
}
}
@@ -507,7 +508,6 @@ function activateNav() {
var target = navLink();
if (target) {
target.classList.toggle('active', true);
target.removeAttribute('href');
}
while (target) {
while (target && !(target.classList && target.classList.contains('nav-list-item'))) {