@@ -7,6 +7,7 @@ import { attachInstruction, extractInstruction } from "@atlaskit/pragmatic-drag-
77import { observer } from "mobx-react" ;
88import { useParams , useRouter } from "next/navigation" ;
99import { createRoot } from "react-dom/client" ;
10+ import scrollIntoView from "smooth-scroll-into-view-if-needed" ;
1011import { LinkIcon , Settings , Share2 , LogOut , MoreHorizontal } from "lucide-react" ;
1112import { Disclosure , Transition } from "@headlessui/react" ;
1213// plane imports
@@ -225,7 +226,29 @@ export const SidebarProjectsListItem = observer(function SidebarProjectsListItem
225226 useOutsideClickDetector ( projectRef , ( ) => projectRef ?. current ?. classList ?. remove ( HIGHLIGHT_CLASS ) ) ;
226227
227228 useEffect ( ( ) => {
228- if ( URLProjectId === project ?. id ) setIsProjectListOpen ( true ) ;
229+ let timeoutId : ReturnType < typeof setTimeout > | undefined ;
230+
231+ if ( URLProjectId === project ?. id ) {
232+ setIsProjectListOpen ( true ) ;
233+ // Scroll to active project
234+ if ( projectRef . current ) {
235+ timeoutId = setTimeout ( ( ) => {
236+ if ( projectRef . current ) {
237+ scrollIntoView ( projectRef . current , {
238+ behavior : "smooth" ,
239+ block : "center" ,
240+ scrollMode : "if-needed" ,
241+ } ) ;
242+ }
243+ } , 200 ) ;
244+ }
245+ }
246+
247+ return ( ) => {
248+ if ( timeoutId ) {
249+ clearTimeout ( timeoutId ) ;
250+ }
251+ } ;
229252 } , [ URLProjectId , project ?. id , setIsProjectListOpen ] ) ;
230253
231254 if ( ! project ) return null ;
0 commit comments