Skip to content

Commit ba368bf

Browse files
committed
Added the Feature of Keeping the Sidebar State in the Admin Portal Only within the Session and not by localStorage.
1 parent 76da1d1 commit ba368bf

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

WebApplication2/Site.Master

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,22 @@
1515
var sidebar = document.getElementById("sidebar");
1616
if (sidebar) {
1717
// Restore scroll position
18-
var scrollPosition = localStorage.getItem("sidebarScrollPosition");
18+
var scrollPosition = sessionStorage.getItem("sidebarScrollPosition");
1919
if (scrollPosition) {
2020
sidebar.scrollTop = scrollPosition;
2121
}
2222

2323
// Save scroll position
24-
sidebar.addEventListener("scroll", function() {
25-
localStorage.setItem("sidebarScrollPosition", sidebar.scrollTop);
24+
sidebar.addEventListener("scroll", function () {
25+
sessionStorage.setItem("sidebarScrollPosition", sidebar.scrollTop);
2626
});
2727
}
2828
});
29+
30+
// Function to clear scroll position
31+
function clearScrollPosition() {
32+
sessionStorage.removeItem("sidebarScrollPosition");
33+
}
2934
</script>
3035
</head>
3136
<body>
@@ -39,7 +44,7 @@
3944
<div>
4045
<asp:ContentPlaceHolder ID="Header" runat="server" />
4146
</div>
42-
<a href="/Pages/Login/Login.aspx" class="back-button">Logout</a>
47+
<a href="/Pages/Login/Login.aspx" onclick="clearScrollPosition();" class="back-button">Logout</a>
4348
</div>
4449
<div class="content">
4550
<asp:ContentPlaceHolder ID="MainContent" runat="server" />

0 commit comments

Comments
 (0)