:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(dashboards): auto-collapse folder tree on mobile (#67654)
Vasco de Krijger842fc432c2ad
diff --git a/products/dashboards/frontend/components/DashboardsTree.tsx b/products/dashboards/frontend/components/DashboardsTree.tsxindex 57ec45d9a8fa..9dcd813afde6 100644--- a/products/dashboards/frontend/components/DashboardsTree.tsx+++ b/products/dashboards/frontend/components/DashboardsTree.tsx@@ -1,6 +1,7 @@+import clsx from 'clsx'import { useActions, useValues } from 'kea'-import { IconCollapse, IconExpand } from '@posthog/icons'+import { IconChevronRight, IconCollapse, IconExpand } from '@posthog/icons'import { LemonButton, Spinner } from '@posthog/lemon-ui'import { LemonTree, TreeDataItem } from 'lib/lemon-ui/LemonTree/LemonTree'@@ -58,8 +59,10 @@ export function DashboardsTree(): JSX.Element {folderDashboardCounts,dashboardFileSystemEntriesLoading,folderEntriesLoading,+ isTreePanelExpanded,} = useValues(dashboardsFileSystemLogic)- const { navigateToFolder, toggleFolder, setExpandedFolders } = useActions(dashboardsFileSystemLogic)+ const { navigateToFolder, toggleFolder, setExpandedFolders, toggleTreePanel } =+ useActions(dashboardsFileSystemLogic)const { reportDashboardsTreeFolderNavigated } = useActions(eventUsageLogic)const { dashboardsLoading } = useValues(dashboardsModel)@@ -80,8 +83,23 @@ export function DashboardsTree(): JSX.Element {return (<div className="grid grid-cols-1 gap-4 md:grid-cols-[260px_1fr]" data-attr="dashboards-tree">+ {/* Hidden on desktop, where the panel is always shown beside the table. */}+ <LemonButton+ size="small"+ type="secondary"+ icon={<IconChevronRight className={clsx('transition-transform', isTreePanelExpanded && 'rotate-90')} />}+ onClick={toggleTreePanel}+ className="md:hidden col-span-full justify-self-start"+ data-attr="dashboards-tree-panel-toggle"+ >+ {isTreePanelExpanded ? 'Hide folders' : 'Browse folders'}+ </LemonButton><div- className="flex flex-col border-b border-border pb-2 md:border-b-0 md:border-r md:pb-0 md:pr-2"+ // Collapsed hides the panel on mobile; md:flex keeps it visible on desktop regardless.+ className={clsx(+ 'flex-col border-b border-border pb-2 md:border-b-0 md:border-r md:pb-0 md:pr-2',+ isTreePanelExpanded ? 'flex' : 'hidden md:flex'+ )}aria-label="Folder tree">{/* LemonTree drops its own className, so the override lives on this wrapper instead. Everydiff --git a/products/dashboards/frontend/logics/dashboardsFileSystemLogic.ts b/products/dashboards/frontend/logics/dashboardsFileSystemLogic.tsindex 4296e3d96ebb..1588e6c75a2d 100644--- a/products/dashboards/frontend/logics/dashboardsFileSystemLogic.ts+++ b/products/dashboards/frontend/logics/dashboardsFileSystemLogic.ts@@ -84,6 +84,8 @@ export const dashboardsFileSystemLogic = kea<dashboardsFileSystemLogicType>([toggleFolder: (folder: string) => ({ folder }),// Replace the whole expanded-folders map at once (Expand all / Collapse all).setExpandedFolders: (folders: Record<string, boolean>) => ({ folders }),+ // Mobile-only panel toggle; desktop shows the panel unconditionally via CSS.+ toggleTreePanel: true,// Create a folder inside `parentPath` ('' = root; defaults to the selected folder when omitted).createFolder: (name: string, parentPath?: string) => ({ name, parentPath }),// Rename a folder — moves it to a sibling path carrying the new name (descendants re-path server-side).@@ -127,6 +129,13 @@ export const dashboardsFileSystemLogic = kea<dashboardsFileSystemLogicType>([setExpandedFolders: (_, { folders }) => folders,},],+ // Not persisted, so mobile always opens with the panel collapsed and the dashboards list front and centre.+ isTreePanelExpanded: [+ false,+ {+ toggleTreePanel: (state) => !state,+ },+ ],}),selectors({entryByRef: [