Skip to content

Commit 301c030

Browse files
committed
fix: preserve nav indicator element across re-renders for smooth animation
1 parent 393ef2b commit 301c030

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

public/js/app.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,9 +1193,15 @@ function renderSidebarNav() {
11931193
const nav = $('#sidebar-nav');
11941194
if (!nav) return;
11951195

1196+
let indicator = document.getElementById('nav-indicator');
1197+
if (!indicator) {
1198+
indicator = document.createElement('div');
1199+
indicator.className = 'nav-indicator';
1200+
indicator.id = 'nav-indicator';
1201+
}
1202+
11961203
if (state.sidebarMode === 'account') {
11971204
nav.innerHTML = html`
1198-
<div class="nav-indicator" id="nav-indicator"></div>
11991205
<div class="nav-section-label">Account</div>
12001206
<a class="nav-item ${state.accountTab === 'info' ? 'active' : ''}" data-account-page="info" href="/account/info">
12011207
<i data-lucide="user"></i>
@@ -1219,9 +1225,9 @@ function renderSidebarNav() {
12191225
Back to Dashboard
12201226
</a>
12211227
`;
1228+
nav.prepend(indicator);
12221229
} else {
12231230
nav.innerHTML = html`
1224-
<div class="nav-indicator" id="nav-indicator"></div>
12251231
<div class="nav-section-label">Main</div>
12261232
<a class="nav-item ${state.currentPage === 'overview' ? 'active' : ''}" data-page="overview" href="/">
12271233
<i data-lucide="grid-3x3"></i>
@@ -1276,6 +1282,7 @@ function renderSidebarNav() {
12761282
</a>
12771283
` : ''}
12781284
`;
1285+
nav.prepend(indicator);
12791286
}
12801287

12811288
document.querySelectorAll('.nav-item[data-page]').forEach(item => {

0 commit comments

Comments
 (0)