Skip to content

Commit 74cdaa1

Browse files
committed
Fix expanded service rows collapsing on auto-refresh
Save which slugs are expanded before re-rendering the services table, then restore their expanded state and visible instance rows after the innerHTML replacement.
1 parent 0e5b46d commit 74cdaa1

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

app/static/js/app.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,13 @@ const CP = (() => {
233233
const breakdownMap = {};
234234
(breakdown || []).forEach(b => { breakdownMap[b.platform] = b; });
235235

236+
// Preserve expanded rows across re-renders
237+
const expandedSlugs = new Set();
238+
container.querySelectorAll('.breakdown-row.expanded').forEach(r => {
239+
const slug = r.dataset.slug;
240+
if (slug) expandedSlugs.add(slug);
241+
});
242+
236243
const rows = services.map(svc => renderServiceRow(svc, breakdownMap[svc.slug])).join('');
237244
container.innerHTML = `
238245
<table class="breakdown-table">
@@ -251,6 +258,15 @@ const CP = (() => {
251258
</thead>
252259
<tbody>${rows}</tbody>
253260
</table>`;
261+
262+
// Restore expanded state
263+
expandedSlugs.forEach(slug => {
264+
const mainRow = container.querySelector(`.breakdown-row[data-slug="${slug}"]`);
265+
if (mainRow) {
266+
mainRow.classList.add('expanded');
267+
container.querySelectorAll(`.instance-row[data-parent="${slug}"]`).forEach(r => { r.style.display = ''; });
268+
}
269+
});
254270
} catch (err) {
255271
// Keep existing table if we had one; only show spinner on truly empty state
256272
if (!container.querySelector('.breakdown-table')) {

0 commit comments

Comments
 (0)