Skip to content

Commit

Permalink
feat(ui): Sidebar > on active tab, auto expand parent folder in sideb…
Browse files Browse the repository at this point in the history
…ar if collapsed before scrolling the active tab's collection item into view
  • Loading branch information
flawiddsouza committed Mar 8, 2024
1 parent 62f89d9 commit 605db95
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/ui/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ function setActiveTab(state, tab, scrollSidebarItemIntoView = false, persistActi
state.activeTab = tab
loadResponses(state, tab._id)
if(scrollSidebarItemIntoView) {
if(tab.parentId) {
let currentParentId = tab.parentId
while (currentParentId) {
const parentFolder = findItemInTreeById(state.collectionTree, currentParentId)
if(parentFolder && parentFolder.collapsed) {
parentFolder.collapsed = false
store.dispatch('saveCollectionItemCollapsedState', { _id: parentFolder._id, collapsed: parentFolder.collapsed })
console.log(`parent folder ${parentFolder.name} was collapsed and has been auto expanded`)
}
currentParentId = parentFolder.parentId
}
}
nextTick(() => {
const activeSidebarElement = document.querySelector(`.sidebar-list-container div[data-id="${tab._id}"]`)
if(activeSidebarElement) {
Expand Down

0 comments on commit 605db95

Please sign in to comment.