File tree Expand file tree Collapse file tree
frontend/src/components/HomeComponents/Navbar Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -106,6 +106,23 @@ export const NavbarMobile = (
106106 props . setIsOpen ( false ) ;
107107 } ;
108108
109+ const handleNavClick = (
110+ e : React . MouseEvent < HTMLAnchorElement > ,
111+ href : string
112+ ) => {
113+ e . preventDefault ( ) ;
114+ props . setIsOpen ( false ) ;
115+
116+ // Wait for sheet to close, then scroll
117+ setTimeout ( ( ) => {
118+ const targetId = href . replace ( '#' , '' ) ;
119+ const element = document . getElementById ( targetId ) ;
120+ if ( element ) {
121+ element . scrollIntoView ( { behavior : 'smooth' , block : 'start' } ) ;
122+ }
123+ } , 300 ) ;
124+ } ;
125+
109126 return (
110127 < span className = "flex md:hidden" >
111128 < ModeToggle />
@@ -132,7 +149,7 @@ export const NavbarMobile = (
132149 rel = "noreferrer noopener"
133150 key = { label }
134151 href = { href }
135- onClick = { ( ) => props . setIsOpen ( false ) }
152+ onClick = { ( e ) => handleNavClick ( e , href ) }
136153 className = { buttonVariants ( { variant : 'ghost' } ) }
137154 >
138155 { label }
You can’t perform that action at this time.
0 commit comments