fix(list): toggle a checkbox in place instead of rebuilding the grid

renderGrid replaces every card, so the scroll container jumped back to the top: ticking a card near the bottom of a long list threw the user back to the first row. Only the affected card and the selection bar are updated now.
This commit is contained in:
r-zakarya
2026-08-01 23:59:53 +01:00
parent 29ba069659
commit a12f3a2c91
2 changed files with 23 additions and 1 deletions
+17 -1
View File
@@ -3573,7 +3573,23 @@ let selectionAnchor = null; // last single-clicked card, used for shift+click r
function toggleChecked(id) {
if (state.checked.has(id)) state.checked.delete(id);
else state.checked.add(id);
renderGrid();
// In place, not renderGrid(): rebuilding the grid replaces every card, and
// the scroll container jumps back to the top — ticking a card near the
// bottom of a long list threw the user back to the first row.
const on = state.checked.has(id);
document.querySelectorAll(
'.entry-card[data-id="' + id + '"], .entry-row[data-id="' + id + '"]'
).forEach(node => {
node.classList.toggle('is-checked', on);
const box = node.querySelector('.entry-check');
if (!box) return;
box.classList.toggle('is-checked', on);
box.title = on ? 'Deselect' : 'Select';
// The tick is a child element added at render time, not CSS content.
box.textContent = '';
if (on) box.appendChild(el('span', null, '✓'));
});
renderBatchBar();
}
function handleCardClick(ev, entry, inTrash) {