1- import type { FC } from "react" ;
2- import React from "react" ;
1+ import React , { useEffect } from "react" ;
32import { observer } from "mobx-react" ;
43// plane imports
54import { EXTENDED_SIDEBAR_WIDTH , SIDEBAR_WIDTH } from "@plane/constants" ;
65import { useLocalStorage } from "@plane/hooks" ;
76import { cn } from "@plane/utils" ;
87// hooks
8+ import { useAppTheme } from "@/hooks/store/use-app-theme" ;
9+ // hooks
910import useExtendedSidebarOutsideClickDetector from "@/hooks/use-extended-sidebar-overview-outside-click" ;
1011
1112type Props = {
13+ className ?: string ;
1214 children : React . ReactNode ;
1315 extendedSidebarRef : React . RefObject < HTMLDivElement > ;
1416 isExtendedSidebarOpened : boolean ;
@@ -17,26 +19,35 @@ type Props = {
1719} ;
1820
1921export const ExtendedSidebarWrapper = observer ( function ExtendedSidebarWrapper ( props : Props ) {
20- const { children, extendedSidebarRef, isExtendedSidebarOpened, handleClose, excludedElementId } = props ;
22+ const { className , children, extendedSidebarRef, isExtendedSidebarOpened, handleClose, excludedElementId } = props ;
2123 // store hooks
24+ const { sidebarCollapsed } = useAppTheme ( ) ;
25+ // local storage
2226 const { storedValue } = useLocalStorage ( "sidebarWidth" , SIDEBAR_WIDTH ) ;
2327
2428 useExtendedSidebarOutsideClickDetector ( extendedSidebarRef , handleClose , excludedElementId ) ;
2529
30+ useEffect ( ( ) => {
31+ if ( sidebarCollapsed ) {
32+ handleClose ( ) ;
33+ }
34+ } , [ sidebarCollapsed , handleClose ] ) ;
35+
2636 return (
2737 < div
2838 id = { excludedElementId }
2939 ref = { extendedSidebarRef }
3040 className = { cn (
31- ` absolute h-full z-[21] flex flex-col py-2 transform transition-all duration-300 ease-in-out bg-custom-sidebar-background-100 border-r border-custom-sidebar-border-200 p-4 shadow-sm` ,
41+ " absolute h-full z-[21] flex flex-col py-2 transform transition-all duration-300 ease-in-out bg-custom-sidebar-background-100 border-r border-custom-sidebar-border-200 p-4 shadow-sm" ,
3242 {
33- "translate-x-0 opacity-100" : isExtendedSidebarOpened ,
34- [ `-translate-x-[${ EXTENDED_SIDEBAR_WIDTH } px] opacity-0 hidden` ] : ! isExtendedSidebarOpened ,
35- }
43+ "opacity-100" : isExtendedSidebarOpened ,
44+ "opacity-0 hidden" : ! isExtendedSidebarOpened ,
45+ } ,
46+ className
3647 ) }
3748 style = { {
3849 left : `${ storedValue ?? SIDEBAR_WIDTH } px` ,
39- width : `${ isExtendedSidebarOpened ? EXTENDED_SIDEBAR_WIDTH : 0 } px` ,
50+ width : `${ EXTENDED_SIDEBAR_WIDTH } px` ,
4051 } }
4152 >
4253 { children }
0 commit comments