From ee62acd3f1fcd8fbd5fbc5e7d9b9fbed3bdc6a59 Mon Sep 17 00:00:00 2001 From: pewdiepie-archdaemon Date: Mon, 1 Jun 2026 14:50:06 +0900 Subject: [PATCH] Fix library space toggles --- static/js/documentLibrary.js | 12 ++++++++---- static/js/ui.js | 5 +++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/static/js/documentLibrary.js b/static/js/documentLibrary.js index f76e5be..977ef83 100644 --- a/static/js/documentLibrary.js +++ b/static/js/documentLibrary.js @@ -87,6 +87,7 @@ let _libraryArchivedView = false; // Documents tab showing archived docs? /** Collapse an expanded card */ function _collapseExpandedCard(card) { const grid = card.closest('.doclib-grid'); + const instant = card?.dataset?.spaceToggle === '1'; card.classList.remove('doclib-card-expanded'); // Release the height lock so grid returns to natural size if (grid) { @@ -97,7 +98,7 @@ let _libraryArchivedView = false; // Documents tab showing archived docs? if (reader) reader.remove(); // Fade siblings back in - if (grid) { + if (grid && !instant) { const siblings = [...grid.querySelectorAll('.doclib-card')].filter(c => c !== card); siblings.forEach(s => { s.style.opacity = '0'; }); requestAnimationFrame(() => { @@ -812,6 +813,7 @@ let _libraryArchivedView = false; // Documents tab showing archived docs? async function libraryExpandCard(card, doc) { const grid = card.closest('.doclib-grid'); + const instant = card?.dataset?.spaceToggle === '1'; // Already expanded — collapse if (card.classList.contains('doclib-card-expanded')) { @@ -829,8 +831,10 @@ let _libraryArchivedView = false; // Documents tab showing archived docs? // Force explicit starting opacity so the first transition works siblings.forEach(s => { s.style.opacity = '1'; }); // Force reflow so the browser registers the starting value - if (siblings.length) siblings[0].offsetHeight; - siblings.forEach(s => { s.style.transition = 'opacity 0.12s ease'; s.style.opacity = '0'; }); + if (!instant) { + if (siblings.length) siblings[0].offsetHeight; + siblings.forEach(s => { s.style.transition = 'opacity 0.12s ease'; s.style.opacity = '0'; }); + } // Capture the full grid + toolbar height so the modal stays the same // size on desktop. On mobile the modal is full-height and we want the @@ -844,7 +848,7 @@ let _libraryArchivedView = false; // Documents tab showing archived docs? } // Wait for fade-out, then expand - await new Promise(r => setTimeout(r, 120)); + if (!instant) await new Promise(r => setTimeout(r, 120)); card.classList.add('doclib-card-expanded'); if (grid) grid.scrollTop = 0; diff --git a/static/js/ui.js b/static/js/ui.js index c018023..dae3b62 100644 --- a/static/js/ui.js +++ b/static/js/ui.js @@ -29,6 +29,7 @@ function _targetEl(target) { const SPACE_CARD_SELECTOR = [ '#email-lib-modal .doclib-card', '#doclib-modal .doclib-card', + '#doclib-modal .doclib-chat-row', '#memory-modal .doclib-card', '#tasks-modal .task-card', '#tasks-modal .task-log-row', @@ -90,7 +91,11 @@ function _activateSpaceCard(card) { return true; } } + card.dataset.spaceToggle = '1'; card.click(); + setTimeout(() => { + try { delete card.dataset.spaceToggle; } catch {} + }, 0); return true; }