: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(nav): add Create dropdown button behind nav experiment flag (#64051)
Mike Warren183054a22938
diff --git a/frontend/src/layout/panel-layout/ai-first/Nav.tsx b/frontend/src/layout/panel-layout/ai-first/Nav.tsxindex 8983bdbd5651..4ce105867e1f 100644--- a/frontend/src/layout/panel-layout/ai-first/Nav.tsx+++ b/frontend/src/layout/panel-layout/ai-first/Nav.tsx@@ -1,11 +1,11 @@import { Tabs } from '@base-ui/react/tabs'import { cva } from 'cva'-import { useActions, useValues } from 'kea'+import { useActions, useMountedLogic, useValues } from 'kea'import { router } from 'kea-router'import posthog from 'posthog-js'import { lazy, Suspense, useEffect, useRef } from 'react'-import { IconApps, IconChat, IconChevronRight } from '@posthog/icons'+import { IconApps, IconChat, IconChevronRight, IconPlusSmall } from '@posthog/icons'import { NewAccountMenu } from 'lib/components/Account/NewAccountMenu'import { keyBinds } from 'lib/components/AppShortcuts/shortcuts'@@ -13,11 +13,15 @@ import { useAppShortcut } from 'lib/components/AppShortcuts/useAppShortcut'import { commandLogic } from 'lib/components/Command/commandLogic'import { Resizer } from 'lib/components/Resizer/Resizer'import { ResizerLogicProps, resizerLogic } from 'lib/components/Resizer/resizerLogic'+import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'+import { LemonButton } from 'lib/lemon-ui/LemonButton'import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'import { Collapsible } from 'lib/ui/Collapsible/Collapsible'+import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from 'lib/ui/DropdownMenu/DropdownMenu'import { Label } from 'lib/ui/Label/Label'import { WrappingLoadingSkeleton } from 'lib/ui/WrappingLoadingSkeleton/WrappingLoadingSkeleton'import { cn } from 'lib/utils/css-classes'+import { newDashboardLogic } from 'scenes/dashboard/newDashboardLogic'import { urls } from 'scenes/urls'import {@@ -30,6 +34,7 @@ import {import { NavSearchButton } from '../../../lib/components/NavSearchButton/NavSearchButton'import { navigation3000Logic } from '../../navigation-3000/navigationLogic'+import { CreateMenu } from '../menus/CreateMenu'import { NavBarFooter } from '../NavBarFooter'import { PanelLayoutPanels } from './PanelLayoutPanels'import { NavTabBrowse } from './tabs/NavTabBrowse'@@ -97,6 +102,13 @@ const TAB_CONFIG: { id: NavExperimentTab; label: string; icon: JSX.Element }[] ={ id: 'chat', label: 'Chat', icon: <IconChat className="text-ai" /> },]+// Keeps newDashboardLogic mounted while the Create button is visible, so the "Start from scratch"+// flow completes (and redirects) even after the menu closes and unmounts its own logic reference.+function CreateMenuLogics(): null {+ useMountedLogic(newDashboardLogic)+ return null+}+export function Nav(): JSX.Element {const containerRef = useRef<HTMLDivElement | null>(null)const {@@ -111,6 +123,7 @@ export function Nav(): JSX.Element {useValues(panelLayoutLogic)const { mobileLayout: isMobileLayout } = useValues(navigation3000Logic)const { toggleCommand } = useActions(commandLogic)+ const showCreateButton = useFeatureFlag('CREATE_BUTTON_NAV_EXPERIMENT', 'test')const resizerLogicProps: ResizerLogicProps = {logicKey: 'panel-layout-navbar',@@ -217,6 +230,36 @@ export function Nav(): JSX.Element {</div></div>+ {showCreateButton && (+ <div className={cn('px-2 py-1', isLayoutNavCollapsed && 'flex justify-center px-0')}>+ <CreateMenuLogics />+ <DropdownMenu+ onOpenChange={(open) => {+ if (open) {+ posthog.capture('nav create button clicked')+ }+ }}+ >+ <DropdownMenuTrigger asChild>+ <LemonButton+ type="primary"+ size="small"+ icon={<IconPlusSmall />}+ fullWidth={!isLayoutNavCollapsed}+ center={!isLayoutNavCollapsed}+ title={isLayoutNavCollapsed ? 'Create' : undefined}+ data-attr="nav-create-button"+ >+ {!isLayoutNavCollapsed ? 'Create' : null}+ </LemonButton>+ </DropdownMenuTrigger>+ <DropdownMenuContent side="bottom" align="start" className="min-w-[220px]">+ <CreateMenu />+ </DropdownMenuContent>+ </DropdownMenu>+ </div>+ )}+<Tabs.RootclassName="z-[var(--z-main-nav)] flex flex-col flex-1 overflow-hidden"value={isLayoutNavCollapsed && navExperimentActiveTab === 'chat' ? 'home' : navExperimentActiveTab}diff --git a/frontend/src/layout/panel-layout/menus/CreateMenu.tsx b/frontend/src/layout/panel-layout/menus/CreateMenu.tsxnew file mode 100644index 000000000000..03cdaa282f95--- /dev/null+++ b/frontend/src/layout/panel-layout/menus/CreateMenu.tsx@@ -0,0 +1,201 @@+import { useActions, useValues } from 'kea'+import { router } from 'kea-router'+import posthog from 'posthog-js'+import { ReactNode } from 'react'++import { IconChevronRight, IconSparkles } from '@posthog/icons'++import { TreeDataItem } from 'lib/lemon-ui/LemonTree/LemonTree'+import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'+import {+ DropdownMenuGroup,+ DropdownMenuItem,+ DropdownMenuSeparator,+ DropdownMenuSub,+ DropdownMenuSubContent,+ DropdownMenuSubTrigger,+} from 'lib/ui/DropdownMenu/DropdownMenu'+import { runBlankDashboardFlow } from 'scenes/dashboard/dashboards/templates/dashboardTemplateCreationFlows'+import { newDashboardLogic } from 'scenes/dashboard/newDashboardLogic'+import { maxGlobalLogic } from 'scenes/max/maxGlobalLogic'++import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'+import { projectTreeDataLogic } from '~/layout/panel-layout/ProjectTree/projectTreeDataLogic'+import { splitPath, unescapePath } from '~/layout/panel-layout/ProjectTree/utils'+import { FileSystemIconType } from '~/queries/schema/schema-general'++// Products shown first, in this exact order. Anything not listed follows alphabetically.+const PRIORITY_ORDER = ['Insight', 'Dashboard', 'Notebook', 'Experiment', 'Feature flag']++// Products hidden from the Create menu.+const HIDDEN = new Set(['Action', 'Cohort', 'Data', 'Early access feature', 'Link', 'Product tour'])++// Icon overrides for group (submenu) triggers, keyed by the stable item key.+const GROUP_ICONS: Record<string, FileSystemIconType> = {+ Insight: 'product_analytics',+}++// Stable key for an item, independent of the "New ..." display name the tree assigns.+function keyOf(item: TreeDataItem): string {+ return item.record?.path ?? item.name ?? item.id+}++// Clean, sentence-cased label derived from the path (e.g. "Insight/Funnel" -> "Funnel"),+// avoiding the "New ..." prefix the project tree adds for create links.+function labelFor(item: TreeDataItem): string {+ const last = splitPath(keyOf(item)).pop()+ return unescapePath(last ?? keyOf(item))+}++function rankOf(item: TreeDataItem): number {+ const index = PRIORITY_ORDER.indexOf(keyOf(item))+ return index === -1 ? PRIORITY_ORDER.length : index+}++function sortByPriority(a: TreeDataItem, b: TreeDataItem): number {+ const rankDiff = rankOf(a) - rankOf(b)+ return rankDiff !== 0 ? rankDiff : labelFor(a).localeCompare(labelFor(b), undefined, { sensitivity: 'accent' })+}++function captureItemClicked(item: string): void {+ posthog.capture('nav create menu item clicked', { item })+}++function pushHref(item: TreeDataItem): void {+ if (item.record?.href) {+ router.actions.push(+ typeof item.record.href === 'function' ? item.record.href(item.record.ref) : item.record.href+ )+ }+}++// Records the click and navigates — the shared behavior for every navigational create item.+function navigateToItem(item: TreeDataItem): void {+ captureItemClicked(keyOf(item))+ pushHref(item)+}++// Shared submenu scaffold: a trigger row (icon + label + chevron) that expands to `children`.+function CreateSubMenu({+ item,+ icon,+ children,+}: {+ item: TreeDataItem+ icon: ReactNode+ children: ReactNode+}): JSX.Element {+ return (+ <DropdownMenuSub>+ <DropdownMenuSubTrigger asChild>+ <ButtonPrimitive menuItem data-attr={`create-menu-sub-menu-${keyOf(item)}-button`}>+ {icon}+ {labelFor(item)}+ <IconChevronRight className="ml-auto size-3" />+ </ButtonPrimitive>+ </DropdownMenuSubTrigger>+ <DropdownMenuSubContent>+ <DropdownMenuGroup>{children}</DropdownMenuGroup>+ </DropdownMenuSubContent>+ </DropdownMenuSub>+ )+}++export function CreateMenu(): JSX.Element {+ const { treeItemsNew } = useValues(projectTreeDataLogic)+ const { isLoading } = useValues(newDashboardLogic)+ const { openSidePanelMax } = useActions(maxGlobalLogic)+ const { addDashboard, setIsLoading } = useActions(newDashboardLogic)++ const items = treeItemsNew.filter((item) => !HIDDEN.has(keyOf(item))).sort(sortByPriority)++ return (+ <DropdownMenuGroup>+ <DropdownMenuItem+ asChild+ onClick={(e) => {+ e.stopPropagation()+ captureItemClicked('Create with AI')+ openSidePanelMax()+ }}+ data-attr="create-menu-with-ai-button"+ >+ <ButtonPrimitive menuItem>+ <IconSparkles className="text-accent" />+ Create with AI+ </ButtonPrimitive>+ </DropdownMenuItem>+ <DropdownMenuSeparator />+ {items.map((item): JSX.Element => {+ const itemKey = keyOf(item)+ if (itemKey === 'Dashboard') {+ return (+ <CreateSubMenu key={item.id} item={item} icon={item.icon}>+ <DropdownMenuItem+ asChild+ onClick={(e) => {+ e.stopPropagation()+ captureItemClicked('Dashboard (blank)')+ runBlankDashboardFlow({ isLoading, setIsLoading, addDashboard })+ }}+ data-attr="create-menu-dashboard-blank"+ >+ <ButtonPrimitive menuItem>Start from scratch</ButtonPrimitive>+ </DropdownMenuItem>+ <DropdownMenuItem+ asChild+ onClick={(e) => {+ e.stopPropagation()+ captureItemClicked('Dashboard (templates)')+ pushHref(item)+ }}+ data-attr="create-menu-dashboard-templates"+ >+ <ButtonPrimitive menuItem>View templates</ButtonPrimitive>+ </DropdownMenuItem>+ </CreateSubMenu>+ )+ }+ if (item.children) {+ const groupIcon = GROUP_ICONS[itemKey]+ return (+ <CreateSubMenu key={item.id} item={item} icon={groupIcon ? iconForType(groupIcon) : item.icon}>+ {item.children.map((child) => (+ <DropdownMenuItem+ key={child.id}+ asChild+ onClick={(e) => {+ e.stopPropagation()+ navigateToItem(child)+ }}+ data-attr={`create-menu-sub-menu-${keyOf(child)}-button`}+ >+ <ButtonPrimitive menuItem>+ {child.icon}+ {labelFor(child)}+ </ButtonPrimitive>+ </DropdownMenuItem>+ ))}+ </CreateSubMenu>+ )+ }+ return (+ <DropdownMenuItem+ key={item.id}+ asChild+ onClick={(e) => {+ e.stopPropagation()+ navigateToItem(item)+ }}+ data-attr={`create-menu-new-${itemKey}-button`}+ >+ <ButtonPrimitive menuItem>+ {item.icon}+ {labelFor(item)}+ </ButtonPrimitive>+ </DropdownMenuItem>+ )+ })}+ </DropdownMenuGroup>+ )+}diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex b9beed6f8ef3..30097bb788fd 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -173,6 +173,7 @@ export const FEATURE_FLAGS = {HALLOWEEN_OVERRIDE: 'halloween-override', // owner: #team-growth, overrides the checks for Halloween to return true when this is enabled// UX flags, used to control the UX of the app+ CREATE_BUTTON_NAV_EXPERIMENT: 'create-button-nav-experiment', // owner: #team-platform-ux multivariate=control,test — adds a Create dropdown to the top of the Browse tab in the left navSTARRED_REORDER: 'starred-reorder', // owner: #team-platform-ux, drag-and-drop reorder of starred shortcuts in the side panelUX_HIDE_PROJECT_NOTICE: 'ux-hide-project-notice', // owner: #team-platform-ux, hides the project notice banner across all scenes