Skip to content

Commit c005fe4

Browse files
committed
fix(explorer): properly respect folderDefaultState (closes #1827)
1 parent 580c1bd commit c005fe4

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

quartz/components/scripts/explorer.inline.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ async function setupExplorer(currentSlug: FullSlug) {
161161
// Get folder state from local storage
162162
const storageTree = localStorage.getItem("fileTree")
163163
const serializedExplorerState = storageTree && opts.useSavedState ? JSON.parse(storageTree) : []
164-
const oldIndex = new Map(
164+
const oldIndex = new Map<string, boolean>(
165165
serializedExplorerState.map((entry: FolderState) => [entry.path, entry.collapsed]),
166166
)
167167

@@ -186,10 +186,14 @@ async function setupExplorer(currentSlug: FullSlug) {
186186

187187
// Get folder paths for state management
188188
const folderPaths = trie.getFolderPaths()
189-
currentExplorerState = folderPaths.map((path) => ({
190-
path,
191-
collapsed: oldIndex.get(path) === true,
192-
}))
189+
currentExplorerState = folderPaths.map((path) => {
190+
const previousState = oldIndex.get(path)
191+
return {
192+
path,
193+
collapsed:
194+
previousState === undefined ? opts.folderDefaultState === "collapsed" : previousState,
195+
}
196+
})
193197

194198
const explorerUl = explorer.querySelector(".explorer-ul")
195199
if (!explorerUl) continue

0 commit comments

Comments
 (0)