Skip to content

Commit

Permalink
Improvement: Add prefixes to the sessionStorage keys in the scrollspy…
Browse files Browse the repository at this point in the history
… implementation, resolves #598. (#599)
  • Loading branch information
abias authored Mar 19, 2024
1 parent b870a6e commit 2a08c72
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Changes

### Unreleased

* 2024-03-18 - Improvement: Add prefixes to the sessionStorage keys in the scrollspy implementation, resolves #598.
* 2024-03-18 - Improvement: Switch to the active Boost Union admin sub-tab after saving a setting and the following page reload, resolves #468.
* 2024-03-16 - Feature: Show the logged-in user's full name in the user menu, resolves #439.
* 2024-03-16 - Bugfix: Leave the last item's link in the breadcrumb only if it's really needed, resolves #595
Expand Down
2 changes: 1 addition & 1 deletion amd/build/scrollspy.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion amd/build/scrollspy.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions amd/src/scrollspy.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const initScrollSpy = () => {
}
editToggle.addEventListener('click', () => {

window.sessionStorage.setItem('edittoggled', true);
window.sessionStorage.setItem('theme_boost_union_scrollspy_edittoggled', true);

let viewporttop = window.scrollY;
let closest = null;
Expand All @@ -61,14 +61,14 @@ const initScrollSpy = () => {
}
});

window.sessionStorage.setItem('closestid', closest.id);
window.sessionStorage.setItem('closestdelta', viewporttop - closest.offsetTop);
window.sessionStorage.setItem('theme_boost_union_scrollspy_closestid', closest.id);
window.sessionStorage.setItem('theme_boost_union_scrollspy_closestdelta', viewporttop - closest.offsetTop);
});
let edittoggled = window.sessionStorage.getItem('edittoggled');
let edittoggled = window.sessionStorage.getItem('theme_boost_union_scrollspy_edittoggled');
if (edittoggled) {

let closestid = window.sessionStorage.getItem('closestid');
let closestdelta = window.sessionStorage.getItem('closestdelta');
let closestid = window.sessionStorage.getItem('theme_boost_union_scrollspy_closestid');
let closestdelta = window.sessionStorage.getItem('theme_boost_union_scrollspy_closestdelta');

if (closestid && closestdelta) {
let closest = document.getElementById(closestid);
Expand All @@ -77,9 +77,9 @@ const initScrollSpy = () => {
window.scrollTo(0, y);
}

window.sessionStorage.removeItem('edittoggled');
window.sessionStorage.removeItem('closestid');
window.sessionStorage.removeItem('closestdelta');
window.sessionStorage.removeItem('theme_boost_union_scrollspy_edittoggled');
window.sessionStorage.removeItem('theme_boost_union_scrollspy_closestid');
window.sessionStorage.removeItem('theme_boost_union_scrollspy_closestdelta');
}
}
};
Expand Down

0 comments on commit 2a08c72

Please sign in to comment.