From 34301e43999032266d054447b38deb407494f1cd Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia <121005188+anmolsinghbhatia@users.noreply.github.com> Date: Wed, 28 Feb 2024 19:55:22 +0530 Subject: [PATCH] fix: app sidebar toggle (#3829) --- .../sidebar/sidebar-menu-hamburger-toggle.tsx | 8 ++-- web/components/project/sidebar-list-item.tsx | 2 +- web/components/workspace/help-section.tsx | 33 +++++++------ web/components/workspace/sidebar-dropdown.tsx | 7 ++- web/components/workspace/sidebar-menu.tsx | 11 +++-- web/layouts/app-layout/sidebar.tsx | 8 ++-- .../settings-layout/profile/sidebar.tsx | 48 +++++++++++-------- web/store/application/theme.store.ts | 18 ------- 8 files changed, 64 insertions(+), 71 deletions(-) diff --git a/web/components/core/sidebar/sidebar-menu-hamburger-toggle.tsx b/web/components/core/sidebar/sidebar-menu-hamburger-toggle.tsx index cb433de05..0212e4980 100644 --- a/web/components/core/sidebar/sidebar-menu-hamburger-toggle.tsx +++ b/web/components/core/sidebar/sidebar-menu-hamburger-toggle.tsx @@ -5,17 +5,17 @@ import { observer } from "mobx-react"; type Props = { onClick?: () => void; -} +}; export const SidebarHamburgerToggle: FC = observer((props) => { - const { onClick } = props + const { onClick } = props; const { theme: themeStore } = useApplication(); return (
{ - if (onClick) onClick() - else themeStore.toggleMobileSidebar() + if (onClick) onClick(); + else themeStore.toggleSidebar(); }} > diff --git a/web/components/project/sidebar-list-item.tsx b/web/components/project/sidebar-list-item.tsx index 3dbf0d5d0..695e0bce4 100644 --- a/web/components/project/sidebar-list-item.tsx +++ b/web/components/project/sidebar-list-item.tsx @@ -144,7 +144,7 @@ export const ProjectSidebarListItem: React.FC = observer((props) => { const handleProjectClick = () => { if (window.innerWidth < 768) { - themeStore.toggleMobileSidebar(); + themeStore.toggleSidebar(); } }; diff --git a/web/components/workspace/help-section.tsx b/web/components/workspace/help-section.tsx index a61ac1823..0bb77f9c7 100644 --- a/web/components/workspace/help-section.tsx +++ b/web/components/workspace/help-section.tsx @@ -10,7 +10,6 @@ import { FileText, HelpCircle, MessagesSquare, MoveLeft, Zap } from "lucide-reac import { DiscordIcon, GithubIcon, Tooltip } from "@plane/ui"; // assets import packageJson from "package.json"; -import useSize from "hooks/use-window-size"; const helpOptions = [ { @@ -43,11 +42,10 @@ export interface WorkspaceHelpSectionProps { export const WorkspaceHelpSection: React.FC = observer(() => { // store hooks const { - theme: { sidebarCollapsed, toggleSidebar, toggleMobileSidebar }, + theme: { sidebarCollapsed, toggleSidebar }, commandPalette: { toggleShortcutModal }, } = useApplication(); - const [windowWidth] = useSize(); // states const [isNeedHelpOpen, setIsNeedHelpOpen] = useState(false); // refs @@ -60,8 +58,9 @@ export const WorkspaceHelpSection: React.FC = observe return ( <>
{!isCollapsed && (
@@ -72,8 +71,9 @@ export const WorkspaceHelpSection: React.FC = observe @@ -101,9 +102,10 @@ export const WorkspaceHelpSection: React.FC = observe @@ -121,8 +123,9 @@ export const WorkspaceHelpSection: React.FC = observe leaveTo="transform opacity-0 scale-95" >
diff --git a/web/components/workspace/sidebar-dropdown.tsx b/web/components/workspace/sidebar-dropdown.tsx index aeb0a34c2..984bc1caf 100644 --- a/web/components/workspace/sidebar-dropdown.tsx +++ b/web/components/workspace/sidebar-dropdown.tsx @@ -8,7 +8,7 @@ import { mutate } from "swr"; import { Check, ChevronDown, CircleUserRound, LogOut, Mails, PlusSquare, Settings, UserCircle2 } from "lucide-react"; import { usePopper } from "react-popper"; // hooks -import { useApplication, useEventTracker, useUser, useWorkspace } from "hooks/store"; +import { useApplication, useUser, useWorkspace } from "hooks/store"; // hooks import useToast from "hooks/use-toast"; // ui @@ -54,9 +54,8 @@ export const WorkspaceSidebarDropdown = observer(() => { const { workspaceSlug } = router.query; // store hooks const { - theme: { sidebarCollapsed, toggleMobileSidebar }, + theme: { sidebarCollapsed, toggleSidebar }, } = useApplication(); - const { setTrackElement } = useEventTracker(); const { currentUser, updateCurrentUser, isUserInstanceAdmin, signOut } = useUser(); const { currentWorkspace: activeWorkspace, workspaces } = useWorkspace(); // hooks @@ -98,7 +97,7 @@ export const WorkspaceSidebarDropdown = observer(() => { }; const handleItemClick = () => { if (window.innerWidth < 768) { - toggleMobileSidebar(); + toggleSidebar(); } }; const workspacesList = Object.values(workspaces ?? {}); diff --git a/web/components/workspace/sidebar-menu.tsx b/web/components/workspace/sidebar-menu.tsx index 9f3f5e1d6..774a231db 100644 --- a/web/components/workspace/sidebar-menu.tsx +++ b/web/components/workspace/sidebar-menu.tsx @@ -31,7 +31,7 @@ export const WorkspaceSidebarMenu = observer(() => { const handleLinkClick = (itemKey: string) => { if (window.innerWidth < 768) { - themeStore.toggleMobileSidebar(); + themeStore.toggleSidebar(); } captureEvent(SIDEBAR_CLICKED, { destination: itemKey, @@ -52,10 +52,11 @@ export const WorkspaceSidebarMenu = observer(() => { disabled={!themeStore?.sidebarCollapsed} >
{ = observer(() => { const ref = useRef(null); useOutsideClickDetector(ref, () => { - if (themStore.mobileSidebarCollapsed === false) { + if (themStore.sidebarCollapsed === false) { if (window.innerWidth < 768) { - themStore.toggleMobileSidebar(); + themStore.toggleSidebar(); } } }); @@ -31,8 +31,8 @@ export const AppSidebar: FC = observer(() => {
{ const { setToastAlert } = useToast(); // store hooks const { - theme: { sidebarCollapsed, toggleSidebar, toggleMobileSidebar }, + theme: { sidebarCollapsed, toggleSidebar }, } = useApplication(); const { currentUser, currentUserSettings, signOut } = useUser(); const { workspaces } = useWorkspace(); @@ -78,7 +78,7 @@ export const ProfileLayoutSidebar = observer(() => { const handleItemClick = () => { if (window.innerWidth < 768) { - toggleMobileSidebar(); + toggleSidebar(); } }; @@ -113,8 +113,9 @@ export const ProfileLayoutSidebar = observer(() => {
@@ -136,10 +137,11 @@ export const ProfileLayoutSidebar = observer(() => {
{} {!sidebarCollapsed && link.label} @@ -160,17 +162,20 @@ export const ProfileLayoutSidebar = observer(() => { {workspace?.logo && workspace.logo !== "" ? ( {
{} {!sidebarCollapsed && link.label} @@ -208,8 +214,9 @@ export const ProfileLayoutSidebar = observer(() => {