Skip to content

Commit

Permalink
fix: folder issue when selecting nested story
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Apr 21, 2022
1 parent 28f3448 commit e24357a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/histoire/src/client/app/stores/folder.ts
Expand Up @@ -19,14 +19,19 @@ export const useFolderStore = defineStore('folder', () => {
const currentValue = openedFolders.value.get(stringPath)

if (currentValue == null) {
openedFolders.value.set(stringPath, defaultToggleValue)
setFolderOpen(stringPath, defaultToggleValue)
} else if (currentValue) {
openedFolders.value.set(stringPath, false)
setFolderOpen(stringPath, false)
} else {
openedFolders.value.set(stringPath, true)
setFolderOpen(stringPath, true)
}
}

function setFolderOpen (path: Array<string> | string, value: boolean) {
const stringPath = typeof path === 'string' ? path : getStringPath(path)
openedFolders.value.set(stringPath, value)
}

function isFolderOpened (path: Array<string>, defaultValue = false) {
const value = openedFolders.value.get(getStringPath(path))
if (value == null) {
Expand All @@ -37,7 +42,7 @@ export const useFolderStore = defineStore('folder', () => {

function openFileFolders (path: Array<string>) {
for (let pathLength = 1; pathLength < path.length; pathLength++) {
toggleFolder(path.slice(0, pathLength), true)
setFolderOpen(path.slice(0, pathLength), true)
}
}

Expand Down

0 comments on commit e24357a

Please sign in to comment.