@@ -8,7 +8,7 @@ import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/el
88import { attachInstruction , extractInstruction } from "@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item" ;
99import { observer } from "mobx-react" ;
1010import Link from "next/link" ;
11- import { useParams , usePathname } from "next/navigation" ;
11+ import { useParams , usePathname , useRouter } from "next/navigation" ;
1212import { createRoot } from "react-dom/client" ;
1313import {
1414 PenSquare ,
@@ -35,6 +35,7 @@ import {
3535 DropIndicator ,
3636 DragHandle ,
3737 Intake ,
38+ ControlLink ,
3839} from "@plane/ui" ;
3940// components
4041import { Logo } from "@/components/common" ;
@@ -126,7 +127,8 @@ export const SidebarProjectsListItem: React.FC<Props> = observer((props) => {
126127 const actionSectionRef = useRef < HTMLDivElement | null > ( null ) ;
127128 const projectRef = useRef < HTMLDivElement | null > ( null ) ;
128129 const dragHandleRef = useRef < HTMLButtonElement | null > ( null ) ;
129- // router params
130+ // router
131+ const router = useRouter ( ) ;
130132 const { workspaceSlug, projectId : URLProjectId } = useParams ( ) ;
131133 // pathname
132134 const pathname = usePathname ( ) ;
@@ -281,11 +283,16 @@ export const SidebarProjectsListItem: React.FC<Props> = observer((props) => {
281283 else setIsProjectListOpen ( false ) ;
282284 } , [ URLProjectId ] ) ;
283285
286+ const handleItemClick = ( ) => {
287+ if ( ! isProjectListOpen && ! isMobile ) router . push ( `/${ workspaceSlug } /projects/${ project . id } /issues` ) ;
288+ setIsProjectListOpen ( ( prev ) => ! prev ) ;
289+ } ;
290+
284291 return (
285292 < >
286293 < PublishProjectModal isOpen = { publishModalOpen } project = { project } onClose = { ( ) => setPublishModal ( false ) } />
287294 < LeaveProjectModal project = { project } isOpen = { leaveProjectModalOpen } onClose = { ( ) => setLeaveProjectModal ( false ) } />
288- < Disclosure key = { `${ project . id } _${ URLProjectId } ` } ref = { projectRef } defaultOpen = { isProjectListOpen } >
295+ < Disclosure key = { `${ project . id } _${ URLProjectId } ` } ref = { projectRef } defaultOpen = { isProjectListOpen } as = "div" >
289296 < div
290297 id = { `sidebar-${ projectId } -${ projectListType } ` }
291298 className = { cn ( "relative" , {
@@ -328,22 +335,19 @@ export const SidebarProjectsListItem: React.FC<Props> = observer((props) => {
328335 </ Tooltip >
329336 ) }
330337 { isSidebarCollapsed ? (
331- < Link
338+ < ControlLink
332339 href = { `/${ workspaceSlug } /projects/${ project . id } /issues` }
333340 className = { cn ( "flex-grow flex items-center gap-1.5 truncate text-left select-none" , {
334341 "justify-center" : isSidebarCollapsed ,
335342 } ) }
343+ onClick = { handleItemClick }
336344 >
337- < Disclosure . Button
338- as = "button"
339- className = "size-8 aspect-square flex-shrink-0 grid place-items-center"
340- onClick = { ( ) => setIsProjectListOpen ( ! isProjectListOpen ) }
341- >
345+ < Disclosure . Button as = "button" className = "size-8 aspect-square flex-shrink-0 grid place-items-center" >
342346 < div className = "size-4 grid place-items-center flex-shrink-0" >
343347 < Logo logo = { project . logo_props } size = { 16 } />
344348 </ div >
345349 </ Disclosure . Button >
346- </ Link >
350+ </ ControlLink >
347351 ) : (
348352 < >
349353 < Tooltip
@@ -352,21 +356,24 @@ export const SidebarProjectsListItem: React.FC<Props> = observer((props) => {
352356 disabled = { ! isSidebarCollapsed }
353357 isMobile = { isMobile }
354358 >
355- < Link href = { `/${ workspaceSlug } /projects/${ project . id } /issues` } className = "flex-grow flex truncate" >
359+ < ControlLink
360+ href = { `/${ workspaceSlug } /projects/${ project . id } /issues` }
361+ className = "flex-grow flex truncate"
362+ onClick = { handleItemClick }
363+ >
356364 < Disclosure . Button
357365 as = "button"
358366 type = "button"
359367 className = { cn ( "flex-grow flex items-center gap-1.5 text-left select-none w-full" , {
360368 "justify-center" : isSidebarCollapsed ,
361369 } ) }
362- onClick = { ( ) => setIsProjectListOpen ( ! isProjectListOpen ) }
363370 >
364371 < div className = "size-4 grid place-items-center flex-shrink-0" >
365372 < Logo logo = { project . logo_props } size = { 16 } />
366373 </ div >
367374 < p className = "truncate text-sm font-medium text-custom-sidebar-text-200" > { project . name } </ p >
368375 </ Disclosure . Button >
369- </ Link >
376+ </ ControlLink >
370377 </ Tooltip >
371378 < CustomMenu
372379 customButton = {
0 commit comments