From 060d7c2b1c026256c1b2ca7818a72c5776a72868 Mon Sep 17 00:00:00 2001 From: dlynas <118506937+dlynas@users.noreply.github.com> Date: Thu, 14 May 2026 18:03:14 -0400 Subject: [PATCH] fix: preserve manual checkbox state across filter toggles; sort on re-filter Bug 1 (nezreka review): _applyAllFilters was restoring checkboxes from data-initially-checked (stamped once at render) rather than the user's last explicit choice, so manually unchecked albums would flip back to checked after any filter toggle. Fix: stamp data-user-checked via a new _onDiscogCardChange handler on every manual change, and restore from that attribute when it's present. Bug 2 (nezreka review): _resortGrid moved cards to the correct grid but left them in DOM order, so cards returning from the deselected section landed at the end regardless of active sort. Fix: re-apply sortDiscogGrid at the end of _resortGrid. Co-Authored-By: Claude Sonnet 4.6 --- webui/static/library.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/webui/static/library.js b/webui/static/library.js index 65807dff..845d1fac 100644 --- a/webui/static/library.js +++ b/webui/static/library.js @@ -2521,7 +2521,7 @@ function _renderDiscogCard(release, index, completionData) { data-year="${year || '0'}" data-name="${albumName.toLowerCase().replace(/"/g, '"')}" data-variants="${_detectReleaseVariants(albumName).join(' ')}" data-initially-checked="${!isOwned}" style="animation-delay:${index * 0.03}s"> - +
${img ? `` : '
🎵
'} ${statusIcon ? `${statusIcon}` : ''} @@ -2712,7 +2712,7 @@ function _applyAllFilters() { } else if (!shouldFilter && card.dataset.filterOff === 'true') { card.dataset.filterOff = ''; card.classList.remove('discog-card--filtered'); - if (cb) cb.checked = card.dataset.initiallyChecked === 'true'; + if (cb) cb.checked = 'userChecked' in card.dataset ? card.dataset.userChecked === 'true' : card.dataset.initiallyChecked === 'true'; } }); _resortGrid(); @@ -2735,6 +2735,8 @@ function _resortGrid() { if (deselectedSection) deselectedSection.style.display = count > 0 ? '' : 'none'; const countEl = document.getElementById('discog-deselected-count'); if (countEl) countEl.textContent = count; + const sortVal = document.querySelector('.discog-sort-select')?.value; + if (sortVal) sortDiscogGrid(sortVal); } function toggleDeselectedSection() { @@ -2780,6 +2782,12 @@ function _updateSelectToggleBtn() { btn.textContent = allChecked ? 'Deselect All' : 'Select All'; } +function _onDiscogCardChange(cb) { + const card = cb.closest('.discog-card'); + if (card) card.dataset.userChecked = cb.checked; + _updateDiscogFooterCount(); +} + function _updateDiscogFooterCount() { let releases = 0, tracks = 0; document.querySelectorAll('.discog-card-cb:checked').forEach(cb => {