@@ -49,34 +49,24 @@ import {
4949import { useCurrentUser } from "@posthog/ui/features/auth/useCurrentUser" ;
5050import { useProjects } from "@posthog/ui/features/projects/useProjects" ;
5151import { openSettings } from "@posthog/ui/features/settings/hooks/useOpenSettings" ;
52- import {
53- holdSidebarPeek ,
54- releaseSidebarPeek ,
55- } from "@posthog/ui/features/sidebar/sidebarPeekStore" ;
52+ import { useHoldSidebarPeek } from "@posthog/ui/features/sidebar/useHoldSidebarPeek" ;
5653import { useWhatsNewStore } from "@posthog/ui/features/updates/whatsNewStore" ;
5754import { openExternalUrl } from "@posthog/ui/shell/openExternal" ;
5855import { isMac } from "@posthog/ui/utils/platform" ;
5956import { getPostHogUrl } from "@posthog/ui/utils/urls" ;
6057import { Avatar , Box } from "@radix-ui/themes" ;
6158import { ChevronRightIcon } from "lucide-react" ;
62- import { type ReactNode , useEffect , useMemo , useState } from "react" ;
59+ import { type ReactNode , useMemo , useState } from "react" ;
6360
6461// The two-line user/project card used at the bottom of the sidebar.
6562export function ProjectSwitcher ( ) {
6663 const [ popoverOpen , setPopoverOpen ] = useState ( false ) ;
6764
68- // Hold the sidebar's hover-peek open while this dropdown is open: it lives in
69- // a portal anchored to the trigger, so if the peek collapsed underneath it
70- // (pointer leaving the panel, e.g. toward a submenu flyout) the menu would be
71- // left floating over the content, chasing its vanished anchor.
65+ const holdPeek = useHoldSidebarPeek ( ) ;
7266 const handleOpenChange = ( next : boolean ) : void => {
7367 setPopoverOpen ( next ) ;
74- if ( next ) holdSidebarPeek ( ) ;
75- else releaseSidebarPeek ( ) ;
68+ holdPeek ( next ) ;
7669 } ;
77- // Release if we unmount while the menu is open (e.g. a route change) so the
78- // hold can't outlive it.
79- useEffect ( ( ) => ( ) => releaseSidebarPeek ( ) , [ ] ) ;
8070
8171 const currentOrgId = useAuthStateValue ( ( state ) => state . currentOrgId ) ;
8272 const client = useOptionalAuthenticatedClient ( ) ;
0 commit comments