Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement: Add prefixes to the sessionStorage keys in the scrollspy implementation, resolves #598. #599

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading