Skip to content

useSidebarCurrentFolder Composable ​

File Information ​

  • Path: app/composables/core/layouts/useSidebarCurrentFolder.ts
  • Purpose: Shared state for the sidebar folder tree highlighting; persists current folder so late-mounted tree receives it
  • Type: Core Composable (Layout)

Overview ​

The sidebar tree can mount after the folder details page has already loaded. useSidebarCurrentFolder uses Nuxt useState so that the current folder is stored in a key (sidebar-current-folder) and any late-mounted listener (e.g. useSidebarFolderTree) still receives the correct folder for expand/highlight.

Return Type ​

  • currentFolder: Ref<Folder | null> — Current folder (from folder details page)
  • setCurrentFolder: (folder: Folder | null) => void — Set the current folder

Usage ​

The folder details page (or composable) calls setCurrentFolder(folder) when the folder is loaded. The sidebar tree's useSidebarFolderTree watches currentFolder and reacts to current-folder Mitt events to expand ancestors and highlight the opened folder.

typescript
const { currentFolder, setCurrentFolder } = useSidebarCurrentFolder()
setCurrentFolder(folderFromRoute)