π₯π₯π₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.
TypeScript boardsbug-trackerdjangodockerganttissue-trackerjirajira-alternativekanbanlinearpostgresqlproduct-managementproject-managementproject-planningpythonreactredistypesciptvitework-management
fix: app sidebar toggle (#3829)
Anmol Singh Bhatia34301e439990
diff --git a/web/components/core/sidebar/sidebar-menu-hamburger-toggle.tsx b/web/components/core/sidebar/sidebar-menu-hamburger-toggle.tsxindex cb433de05c..0212e49802 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<Props> = observer((props) => {- const { onClick } = props+ const { onClick } = props;const { theme: themeStore } = useApplication();return (<divclassName="w-7 h-7 flex-shrink-0 rounded flex justify-center items-center bg-custom-background-80 transition-all hover:bg-custom-background-90 cursor-pointer group md:hidden"onClick={() => {- if (onClick) onClick()- else themeStore.toggleMobileSidebar()+ if (onClick) onClick();+ else themeStore.toggleSidebar();}}><Menu size={14} className="text-custom-text-200 group-hover:text-custom-text-100 transition-all" />diff --git a/web/components/project/sidebar-list-item.tsx b/web/components/project/sidebar-list-item.tsxindex 3dbf0d5d0c..695e0bce4f 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<Props> = 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.tsxindex a61ac18233..0bb77f9c74 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-reacimport { DiscordIcon, GithubIcon, Tooltip } from "@plane/ui";// assetsimport 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<WorkspaceHelpSectionProps> = observer(() => {// store hooksconst {- theme: { sidebarCollapsed, toggleSidebar, toggleMobileSidebar },+ theme: { sidebarCollapsed, toggleSidebar },commandPalette: { toggleShortcutModal },} = useApplication();- const [windowWidth] = useSize();// statesconst [isNeedHelpOpen, setIsNeedHelpOpen] = useState(false);// refs@@ -60,8 +58,9 @@ export const WorkspaceHelpSection: React.FC<WorkspaceHelpSectionProps> = observereturn (<><div- className={`flex w-full items-center justify-between gap-1 self-baseline border-t border-custom-border-200 bg-custom-sidebar-background-100 px-4 py-2 ${isCollapsed ? "flex-col" : ""- }`}+ className={`flex w-full items-center justify-between gap-1 self-baseline border-t border-custom-border-200 bg-custom-sidebar-background-100 px-4 py-2 ${+ isCollapsed ? "flex-col" : ""+ }`}>{!isCollapsed && (<div className="w-1/2 cursor-default rounded-md bg-green-500/10 px-2.5 py-1.5 text-center text-sm font-medium text-green-500 outline-none">@@ -72,8 +71,9 @@ export const WorkspaceHelpSection: React.FC<WorkspaceHelpSectionProps> = observe<Tooltip tooltipContent="Shortcuts"><buttontype="button"- className={`grid place-items-center rounded-md p-1.5 text-custom-text-200 outline-none hover:bg-custom-background-90 hover:text-custom-text-100 ${isCollapsed ? "w-full" : ""- }`}+ className={`grid place-items-center rounded-md p-1.5 text-custom-text-200 outline-none hover:bg-custom-background-90 hover:text-custom-text-100 ${+ isCollapsed ? "w-full" : ""+ }`}onClick={() => toggleShortcutModal(true)}><Zap className="h-3.5 w-3.5" />@@ -82,8 +82,9 @@ export const WorkspaceHelpSection: React.FC<WorkspaceHelpSectionProps> = observe<Tooltip tooltipContent="Help"><buttontype="button"- className={`grid place-items-center rounded-md p-1.5 text-custom-text-200 outline-none hover:bg-custom-background-90 hover:text-custom-text-100 ${isCollapsed ? "w-full" : ""- }`}+ className={`grid place-items-center rounded-md p-1.5 text-custom-text-200 outline-none hover:bg-custom-background-90 hover:text-custom-text-100 ${+ isCollapsed ? "w-full" : ""+ }`}onClick={() => setIsNeedHelpOpen((prev) => !prev)}><HelpCircle className="h-3.5 w-3.5" />@@ -93,7 +94,7 @@ export const WorkspaceHelpSection: React.FC<WorkspaceHelpSectionProps> = observe<buttontype="button"className="grid place-items-center rounded-md p-1.5 text-custom-text-200 outline-none hover:bg-custom-background-90 hover:text-custom-text-100 md:hidden"- onClick={() => windowWidth <= 768 ? toggleMobileSidebar() : toggleSidebar()}+ onClick={() => toggleSidebar()}><MoveLeft className="h-3.5 w-3.5" /></button>@@ -101,9 +102,10 @@ export const WorkspaceHelpSection: React.FC<WorkspaceHelpSectionProps> = observe<Tooltip tooltipContent={`${isCollapsed ? "Expand" : "Hide"}`}><buttontype="button"- className={`hidden place-items-center rounded-md p-1.5 text-custom-text-200 outline-none hover:bg-custom-background-90 hover:text-custom-text-100 md:grid ${isCollapsed ? "w-full" : ""- }`}- onClick={() => windowWidth <= 768 ? toggleMobileSidebar() : toggleSidebar()}+ className={`hidden place-items-center rounded-md p-1.5 text-custom-text-200 outline-none hover:bg-custom-background-90 hover:text-custom-text-100 md:grid ${+ isCollapsed ? "w-full" : ""+ }`}+ onClick={() => toggleSidebar()}><MoveLeft className={`h-3.5 w-3.5 duration-300 ${isCollapsed ? "rotate-180" : ""}`} /></button>@@ -121,8 +123,9 @@ export const WorkspaceHelpSection: React.FC<WorkspaceHelpSectionProps> = observeleaveTo="transform opacity-0 scale-95"><div- className={`absolute bottom-2 min-w-[10rem] ${isCollapsed ? "left-full" : "-left-[75px]"- } divide-y divide-custom-border-200 whitespace-nowrap rounded bg-custom-background-100 p-1 shadow-custom-shadow-xs`}+ className={`absolute bottom-2 min-w-[10rem] ${+ isCollapsed ? "left-full" : "-left-[75px]"+ } divide-y divide-custom-border-200 whitespace-nowrap rounded bg-custom-background-100 p-1 shadow-custom-shadow-xs`}ref={helpOptionsRef}><div className="space-y-1 pb-2">diff --git a/web/components/workspace/sidebar-dropdown.tsx b/web/components/workspace/sidebar-dropdown.tsxindex aeb0a34c2e..984bc1caf3 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";// hooksimport useToast from "hooks/use-toast";// ui@@ -54,9 +54,8 @@ export const WorkspaceSidebarDropdown = observer(() => {const { workspaceSlug } = router.query;// store hooksconst {- 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.tsxindex 9f3f5e1d62..774a231db7 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}><div- className={`group flex w-full items-center gap-2.5 rounded-md px-3 py-2 text-sm font-medium outline-none ${link.highlight(router.asPath, `/${workspaceSlug}`)- ? "bg-custom-primary-100/10 text-custom-primary-100"- : "text-custom-sidebar-text-200 hover:bg-custom-sidebar-background-80 focus:bg-custom-sidebar-background-80"- } ${themeStore?.sidebarCollapsed ? "justify-center" : ""}`}+ className={`group flex w-full items-center gap-2.5 rounded-md px-3 py-2 text-sm font-medium outline-none ${+ link.highlight(router.asPath, `/${workspaceSlug}`)+ ? "bg-custom-primary-100/10 text-custom-primary-100"+ : "text-custom-sidebar-text-200 hover:bg-custom-sidebar-background-80 focus:bg-custom-sidebar-background-80"+ } ${themeStore?.sidebarCollapsed ? "justify-center" : ""}`}>{<link.Icondiff --git a/web/layouts/app-layout/sidebar.tsx b/web/layouts/app-layout/sidebar.tsxindex 8477525d4a..c3b47d0218 100644--- a/web/layouts/app-layout/sidebar.tsx+++ b/web/layouts/app-layout/sidebar.tsx@@ -20,9 +20,9 @@ export const AppSidebar: FC<IAppSidebar> = observer(() => {const ref = useRef<HTMLDivElement>(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<IAppSidebar> = observer(() => {<divclassName={`inset-y-0 z-20 flex h-full flex-shrink-0 flex-grow-0 flex-col border-r border-custom-sidebar-border-200 bg-custom-sidebar-background-100 duration-300fixed md:relative- ${themStore.mobileSidebarCollapsed ? "-ml-[280px]" : ""}- sm:${themStore.mobileSidebarCollapsed ? "-ml-[280px]" : ""}+ ${themStore.sidebarCollapsed ? "-ml-[280px]" : ""}+ sm:${themStore.sidebarCollapsed ? "-ml-[280px]" : ""}md:ml-0 ${themStore.sidebarCollapsed ? "w-[80px]" : "w-[280px]"}lg:ml-0 ${themStore.sidebarCollapsed ? "w-[80px]" : "w-[280px]"}`}diff --git a/web/layouts/settings-layout/profile/sidebar.tsx b/web/layouts/settings-layout/profile/sidebar.tsxindex fc0bf7435f..85f82961fe 100644--- a/web/layouts/settings-layout/profile/sidebar.tsx+++ b/web/layouts/settings-layout/profile/sidebar.tsx@@ -40,7 +40,7 @@ export const ProfileLayoutSidebar = observer(() => {const { setToastAlert } = useToast();// store hooksconst {- 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(() => {<div ref={ref} className="flex h-full w-full flex-col gap-y-4"><Link href={`/${redirectWorkspaceSlug}`} onClick={handleItemClick}><div- className={`flex flex-shrink-0 items-center gap-2 truncate px-4 pt-4 ${sidebarCollapsed ? "justify-center" : ""- }`}+ className={`flex flex-shrink-0 items-center gap-2 truncate px-4 pt-4 ${+ sidebarCollapsed ? "justify-center" : ""+ }`}><span className="grid h-5 w-5 flex-shrink-0 place-items-center"><ChevronLeft className="h-5 w-5" strokeWidth={1} />@@ -136,10 +137,11 @@ export const ProfileLayoutSidebar = observer(() => {<Link key={link.key} href={link.href} className="block w-full" onClick={handleItemClick}><Tooltip tooltipContent={link.label} position="right" className="ml-2" disabled={!sidebarCollapsed}><div- className={`group flex w-full items-center gap-2.5 rounded-md px-3 py-2 text-sm font-medium outline-none ${link.highlight(router.pathname)- ? "bg-custom-primary-100/10 text-custom-primary-100"- : "text-custom-sidebar-text-200 hover:bg-custom-sidebar-background-80"- } ${sidebarCollapsed ? "justify-center" : ""}`}+ className={`group flex w-full items-center gap-2.5 rounded-md px-3 py-2 text-sm font-medium outline-none ${+ link.highlight(router.pathname)+ ? "bg-custom-primary-100/10 text-custom-primary-100"+ : "text-custom-sidebar-text-200 hover:bg-custom-sidebar-background-80"+ } ${sidebarCollapsed ? "justify-center" : ""}`}>{<link.Icon className="h-4 w-4" />}{!sidebarCollapsed && link.label}@@ -160,17 +162,20 @@ export const ProfileLayoutSidebar = observer(() => {<Linkkey={workspace.id}href={`/${workspace.slug}`}- className={`flex flex-grow cursor-pointer select-none items-center truncate text-left text-sm font-medium ${sidebarCollapsed ? "justify-center" : `justify-between`- }`}+ className={`flex flex-grow cursor-pointer select-none items-center truncate text-left text-sm font-medium ${+ sidebarCollapsed ? "justify-center" : `justify-between`+ }`}onClick={handleItemClick}><span- className={`flex w-full flex-grow items-center gap-x-2 truncate rounded-md px-3 py-1 hover:bg-custom-sidebar-background-80 ${sidebarCollapsed ? "justify-center" : ""- }`}+ className={`flex w-full flex-grow items-center gap-x-2 truncate rounded-md px-3 py-1 hover:bg-custom-sidebar-background-80 ${+ sidebarCollapsed ? "justify-center" : ""+ }`}><span- className={`relative flex h-6 w-6 flex-shrink-0 items-center justify-center p-2 text-xs uppercase ${!workspace?.logo && "rounded bg-custom-primary-500 text-white"- }`}+ className={`relative flex h-6 w-6 flex-shrink-0 items-center justify-center p-2 text-xs uppercase ${+ !workspace?.logo && "rounded bg-custom-primary-500 text-white"+ }`}>{workspace?.logo && workspace.logo !== "" ? (<img@@ -195,8 +200,9 @@ export const ProfileLayoutSidebar = observer(() => {<Link className="block w-full" key={link.key} href={link.href} onClick={handleItemClick}><Tooltip tooltipContent={link.label} position="right" className="ml-2" disabled={!sidebarCollapsed}><div- className={`group flex w-full items-center gap-2.5 rounded-md px-3 py-2 text-sm font-medium text-custom-sidebar-text-200 outline-none hover:bg-custom-sidebar-background-80 focus:bg-custom-sidebar-background-80 ${sidebarCollapsed ? "justify-center" : ""- }`}+ className={`group flex w-full items-center gap-2.5 rounded-md px-3 py-2 text-sm font-medium text-custom-sidebar-text-200 outline-none hover:bg-custom-sidebar-background-80 focus:bg-custom-sidebar-background-80 ${+ sidebarCollapsed ? "justify-center" : ""+ }`}>{<link.Icon className="h-4 w-4" />}{!sidebarCollapsed && link.label}@@ -208,8 +214,9 @@ export const ProfileLayoutSidebar = observer(() => {</div><div className="flex flex-shrink-0 flex-grow items-end px-6 py-2"><div- className={`flex w-full ${sidebarCollapsed ? "flex-col justify-center gap-2" : "items-center justify-between gap-2"- }`}+ className={`flex w-full ${+ sidebarCollapsed ? "flex-col justify-center gap-2" : "items-center justify-between gap-2"+ }`}><buttontype="button"@@ -229,8 +236,9 @@ export const ProfileLayoutSidebar = observer(() => {</button><buttontype="button"- className={`ml-auto hidden place-items-center rounded-md p-1.5 text-custom-text-200 outline-none hover:bg-custom-background-90 hover:text-custom-text-100 md:grid ${sidebarCollapsed ? "w-full" : ""- }`}+ className={`ml-auto hidden place-items-center rounded-md p-1.5 text-custom-text-200 outline-none hover:bg-custom-background-90 hover:text-custom-text-100 md:grid ${+ sidebarCollapsed ? "w-full" : ""+ }`}onClick={() => toggleSidebar()}><MoveLeft className={`h-3.5 w-3.5 duration-300 ${sidebarCollapsed ? "rotate-180" : ""}`} />diff --git a/web/store/application/theme.store.ts b/web/store/application/theme.store.tsindex 3873e73868..0f40e86ae3 100644--- a/web/store/application/theme.store.ts+++ b/web/store/application/theme.store.ts@@ -6,14 +6,12 @@ import { applyTheme, unsetCustomCssVariables } from "helpers/theme.helper";export interface IThemeStore {// observablestheme: string | null;- mobileSidebarCollapsed: boolean | undefined;sidebarCollapsed: boolean | undefined;profileSidebarCollapsed: boolean | undefined;workspaceAnalyticsSidebarCollapsed: boolean | undefined;issueDetailSidebarCollapsed: boolean | undefined;// actionstoggleSidebar: (collapsed?: boolean) => void;- toggleMobileSidebar: (collapsed?: boolean) => void;setTheme: (theme: any) => void;toggleProfileSidebar: (collapsed?: boolean) => void;toggleWorkspaceAnalyticsSidebar: (collapsed?: boolean) => void;@@ -22,7 +20,6 @@ export interface IThemeStore {export class ThemeStore implements IThemeStore {// observables- mobileSidebarCollapsed: boolean | undefined = true;sidebarCollapsed: boolean | undefined = undefined;theme: string | null = null;profileSidebarCollapsed: boolean | undefined = undefined;@@ -34,7 +31,6 @@ export class ThemeStore implements IThemeStore {constructor(_rootStore: any | null = null) {makeObservable(this, {// observable- mobileSidebarCollapsed: observable.ref,sidebarCollapsed: observable.ref,theme: observable.ref,profileSidebarCollapsed: observable.ref,@@ -42,7 +38,6 @@ export class ThemeStore implements IThemeStore {issueDetailSidebarCollapsed: observable.ref,// actiontoggleSidebar: action,- toggleMobileSidebar: action,setTheme: action,toggleProfileSidebar: action,toggleWorkspaceAnalyticsSidebar: action,@@ -66,19 +61,6 @@ export class ThemeStore implements IThemeStore {localStorage.setItem("app_sidebar_collapsed", this.sidebarCollapsed.toString());};- /**- * Toggle mobile sidebar collapsed state- * @param collapsed- */- toggleMobileSidebar = (collapsed?: boolean) => {- if (collapsed === undefined) {- this.mobileSidebarCollapsed = !this.mobileSidebarCollapsed;- } else {- this.mobileSidebarCollapsed = collapsed;- }- localStorage.setItem("mobile_sidebar_collapsed", this.mobileSidebarCollapsed.toString());- };-/*** Toggle the profile sidebar collapsed state* @param collapsed