Skip to content

Commit

Permalink
fix: side menu navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
Khaan25 committed Oct 18, 2024
1 parent e85cbd7 commit c0c8f2d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<StyledTopBarContainer width={width}>
<StyledLeftContainer>
{!isMobile && !isNavigationDrawerOpen && !isSettingsPage && (
{!isMobile && !isNavigationDrawerExpanded && (
<StyledTopBarButtonContainer>
<NavigationDrawerCollapseButton direction="right" />
</StyledTopBarButtonContainer>
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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 (
<StyledCollapseButton
Expand Down

0 comments on commit c0c8f2d

Please sign in to comment.