From 2186b7ee26fcdf74656c4bbf7be8cf065c21106f Mon Sep 17 00:00:00 2001 From: Will Miao <13051207myq@gmail.com> Date: Fri, 7 Mar 2025 17:34:54 +0800 Subject: [PATCH] Improve bulk mode card display handling --- static/js/components/LoraCard.js | 23 +++++++++++++++++++---- static/js/managers/BulkManager.js | 12 ++++++++++-- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/static/js/components/LoraCard.js b/static/js/components/LoraCard.js index e886641d..99985f4d 100644 --- a/static/js/components/LoraCard.js +++ b/static/js/components/LoraCard.js @@ -159,11 +159,26 @@ export function updateCardsForBulkMode(isBulkMode) { document.body.classList.toggle('bulk-mode', isBulkMode); - document.querySelectorAll('.lora-card').forEach(card => { + // Get all lora cards + const loraCards = document.querySelectorAll('.lora-card'); + + loraCards.forEach(card => { + // Get all action containers for this card const actions = card.querySelectorAll('.card-actions'); - actions.forEach(actionGroup => { - actionGroup.style.display = isBulkMode ? 'none' : 'flex'; - }); + + // Handle display property based on mode + if (isBulkMode) { + // Hide actions when entering bulk mode + actions.forEach(actionGroup => { + actionGroup.style.display = 'none'; + }); + } else { + // Ensure actions are visible when exiting bulk mode + actions.forEach(actionGroup => { + // We need to reset to default display style which is flex + actionGroup.style.display = 'flex'; + }); + } }); // Apply selection state to cards if entering bulk mode diff --git a/static/js/managers/BulkManager.js b/static/js/managers/BulkManager.js index d51edeec..b510efe2 100644 --- a/static/js/managers/BulkManager.js +++ b/static/js/managers/BulkManager.js @@ -56,12 +56,20 @@ export class BulkManager { this.hideThumbnailStrip(); } - // Update all cards + // First update all cards' visual state before clearing selection updateCardsForBulkMode(state.bulkMode); - // Clear selection if exiting bulk mode + // Clear selection if exiting bulk mode - do this after updating cards if (!state.bulkMode) { this.clearSelection(); + + // Force a lightweight refresh of the cards to ensure proper display + // This is less disruptive than a full resetAndReload() + document.querySelectorAll('.lora-card').forEach(card => { + // Re-apply normal display mode to all card actions + const actions = card.querySelectorAll('.card-actions, .card-button'); + actions.forEach(action => action.style.display = 'flex'); + }); } }