From 9430700926acb758fa4521bc4546744c2604e233 Mon Sep 17 00:00:00 2001 From: ramki-bruno Date: Thu, 6 Feb 2025 22:59:49 +0530 Subject: [PATCH] Fix: Collectio-items not loading when clicking on chevron icon the first-time --- .../Sidebar/Collections/Collection/index.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js b/packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js index f8e4484bc..3fe00c686 100644 --- a/packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js +++ b/packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js @@ -54,6 +54,16 @@ const Collection = ({ collection, searchText }) => { ); }; + const ensureCollectionIsMounted = () => { + if (collection.mountStatus === 'unmounted') { + dispatch(mountCollection({ + collectionUid: collection.uid, + collectionPathname: collection.pathname, + brunoConfig: collection.brunoConfig + })); + } + } + const hasSearchText = searchText && searchText?.trim()?.length; const collectionIsCollapsed = hasSearchText ? false : collection.collapsed; @@ -67,13 +77,7 @@ const Collection = ({ collection, searchText }) => { const isChevronClick = event.target.closest('svg')?.classList.contains('chevron-icon'); setTimeout(scrollToTheActiveTab, 50); - if (collection.mountStatus === 'unmounted') { - dispatch(mountCollection({ - collectionUid: collection.uid, - collectionPathname: collection.pathname, - brunoConfig: collection.brunoConfig - })); - } + ensureCollectionIsMounted(); dispatch(collapseCollection(collection.uid)); @@ -95,6 +99,7 @@ const Collection = ({ collection, searchText }) => { const handleCollectionCollapse = (e) => { e.stopPropagation(); e.preventDefault(); + ensureCollectionIsMounted(); dispatch(collapseCollection(collection.uid)); }