diff --git a/packages/twenty-front/src/modules/ui/layout/page/PageHeader.tsx b/packages/twenty-front/src/modules/ui/layout/page/PageHeader.tsx index b25f00ae9ac5..4243a2d285f8 100644 --- a/packages/twenty-front/src/modules/ui/layout/page/PageHeader.tsx +++ b/packages/twenty-front/src/modules/ui/layout/page/PageHeader.tsx @@ -110,15 +110,14 @@ export const PageHeader = ({ }: PageHeaderProps) => { const isMobile = useIsMobile(); const theme = useTheme(); - const isNavigationDrawerOpen = useRecoilValue(isNavigationDrawerOpenState); - const { pathname } = useLocation(); - const isSettingsPage = matchPath('/settings/*', pathname); - + const isNavigationDrawerExpanded = useRecoilValue( + isNavigationDrawerExpandedState, + ); return ( - {!isMobile && !isNavigationDrawerOpen && !isSettingsPage && ( + {!isMobile && !isNavigationDrawerExpanded && ( diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerCollapseButton.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerCollapseButton.tsx index 9be3547320b4..8c6aa838cd39 100644 --- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerCollapseButton.tsx +++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerCollapseButton.tsx @@ -1,7 +1,9 @@ +import { useIsSettingsPage } from '@/navigation/hooks/useIsSettingsPage'; import { IconButton } from '@/ui/input/button/components/IconButton'; import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded'; import styled from '@emotion/styled'; -import { useSetRecoilState } from 'recoil'; +import { useEffect } from 'react'; +import { useRecoilValue, useSetRecoilState } from 'recoil'; import { IconLayoutSidebarLeftCollapse, IconLayoutSidebarRightCollapse, @@ -28,9 +30,22 @@ export const NavigationDrawerCollapseButton = ({ className, direction = 'left', }: NavigationDrawerCollapseButtonProps) => { + const isSettingsPage = useIsSettingsPage(); + const setIsNavigationDrawerExpanded = useSetRecoilState( isNavigationDrawerExpandedState, ); + const isNavigationDrawerExpanded = useRecoilValue( + isNavigationDrawerExpandedState, + ); + + // Check if the user is on the settings page and the navigation drawer is not expanded + // Then open it automatically + useEffect(() => { + if (!isNavigationDrawerExpanded && isSettingsPage) { + setIsNavigationDrawerExpanded(true); + } + }, [isSettingsPage]); return (