fix: preserve checkbox selection across table re-renders
CI / Build & Test (push) Successful in 3m1s
CI / Build & Test (push) Successful in 3m1s
Snapshot checked row IDs before each innerHTML swap in the virtual hosts, service tunnels, and server tunnels tables so that periodic refresh cycles no longer reset multi-selection state.
This commit is contained in:
@@ -40,6 +40,10 @@ function updateSwarmsTable(state) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Snapshot checked checkboxes so selection survives the innerHTML swap
|
||||
const _checkedServerIds = new Set();
|
||||
tbody.querySelectorAll('.server-row-cb:checked').forEach(cb => _checkedServerIds.add(cb.dataset.serverId));
|
||||
|
||||
tbody.innerHTML = servers.map(s => {
|
||||
const id = s.id || s.serverId || '';
|
||||
const url = s.url || s.hsUrl || '';
|
||||
@@ -81,6 +85,7 @@ function updateSwarmsTable(state) {
|
||||
}).join('');
|
||||
|
||||
tbody.querySelectorAll('.server-row-cb').forEach(cb => {
|
||||
if (_checkedServerIds.has(cb.dataset.serverId)) cb.checked = true;
|
||||
cb.addEventListener('change', _updateServerBulkBar);
|
||||
});
|
||||
|
||||
|
||||
@@ -36,6 +36,10 @@ function updateServiceTunnelsTable(state) {
|
||||
_latencySnapshot[b.dataset.pingHost + ':' + b.dataset.pingPort] = { text: b.textContent, color: b.style.color };
|
||||
});
|
||||
|
||||
// Snapshot checked checkboxes so selection survives the innerHTML swap
|
||||
const _checkedTunnelIds = new Set();
|
||||
tbody.querySelectorAll('.svc-row-cb:checked').forEach(cb => _checkedTunnelIds.add(cb.dataset.tunnelId));
|
||||
|
||||
if (tunnels.length === 0) {
|
||||
tbody.innerHTML = `
|
||||
<tr><td colspan="6">
|
||||
@@ -111,6 +115,7 @@ function updateServiceTunnelsTable(state) {
|
||||
});
|
||||
|
||||
tbody.querySelectorAll('.svc-row-cb').forEach(cb => {
|
||||
if (_checkedTunnelIds.has(cb.dataset.tunnelId)) cb.checked = true;
|
||||
cb.addEventListener('change', _updateSvcBulkBar);
|
||||
});
|
||||
|
||||
|
||||
@@ -34,6 +34,10 @@ function updateConnectionsTable(state) {
|
||||
_latencySnapshot[b.dataset.pingHost + ':' + b.dataset.pingPort] = { text: b.textContent, color: b.style.color };
|
||||
});
|
||||
|
||||
// Snapshot checked checkboxes so selection survives the innerHTML swap
|
||||
const _checkedHostnames = new Set();
|
||||
tbody.querySelectorAll('.vhost-row-cb:checked').forEach(cb => _checkedHostnames.add(cb.dataset.hostname));
|
||||
|
||||
if (virtualHosts.length === 0) {
|
||||
tbody.innerHTML = `
|
||||
<tr><td colspan="6">
|
||||
@@ -103,6 +107,7 @@ function updateConnectionsTable(state) {
|
||||
});
|
||||
|
||||
tbody.querySelectorAll('.vhost-row-cb').forEach(cb => {
|
||||
if (_checkedHostnames.has(cb.dataset.hostname)) cb.checked = true;
|
||||
cb.addEventListener('change', _updateVhostBulkBar);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user