@@ -27,11 +27,13 @@ const NavigationMobile: React.FC<NavigationMobileProps> = ({ locale, items, butt
2727 const { trigger } = useWebHaptics ( )
2828 const menuRef = useOutsideClick < HTMLElement > ( ( ) => setIsOpen ( false ) )
2929 const rootRef = useRef < HTMLDivElement > ( null )
30+ const menuContentRef = useRef < HTMLDivElement > ( null )
3031 const wasOpenRef = useRef ( false )
3132 const [ isOpen , setIsOpen ] = useState ( false )
3233 const [ mobileOpenKey , setMobileOpenKey ] = useState < string | null > ( null )
3334 const [ isMenuClosing , setIsMenuClosing ] = useState ( false )
3435 const [ shellInsetWidth , setShellInsetWidth ] = useState ( 0 )
36+ const [ menuHeight , setMenuHeight ] = useState ( 0 )
3537 const { homeHref, navbarItems, navbarButtons, logo : navigationLogo } = useNavigationViewModel ( locale , items , buttons , logo )
3638 const menuTransition = {
3739 duration : 0.34 ,
@@ -43,7 +45,7 @@ const NavigationMobile: React.FC<NavigationMobileProps> = ({ locale, items, butt
4345 }
4446 const isShellExpanded = isOpen || isMenuClosing
4547 const isScrolled = useNavigationScrollState ( {
46- onScroll : ( ) => setIsOpen ( ( prevIsOpen ) => ( prevIsOpen ? false : prevIsOpen ) ) ,
48+ onScroll : isOpen ? ( ) => setIsOpen ( false ) : undefined ,
4749 } )
4850 const expandedHeaderPadding = 8
4951 const shellInset = isScrolled && ! isShellExpanded ? shellInsetWidth : 0
@@ -97,6 +99,26 @@ const NavigationMobile: React.FC<NavigationMobileProps> = ({ locale, items, butt
9799 return ( ) => resizeObserver . disconnect ( )
98100 } , [ ] )
99101
102+ useLayoutEffect ( ( ) => {
103+ const element = menuContentRef . current
104+
105+ if ( ! element || ! isOpen ) {
106+ setMenuHeight ( 0 )
107+ return
108+ }
109+
110+ const measure = ( ) => {
111+ setMenuHeight ( element . scrollHeight )
112+ }
113+
114+ measure ( )
115+
116+ const resizeObserver = new ResizeObserver ( measure )
117+ resizeObserver . observe ( element )
118+
119+ return ( ) => resizeObserver . disconnect ( )
120+ } , [ isOpen , navbarItems , navbarButtons ] )
121+
100122 const closeMenu = ( ) => {
101123 trigger ( "medium" )
102124 setIsOpen ( false )
@@ -113,7 +135,7 @@ const NavigationMobile: React.FC<NavigationMobileProps> = ({ locale, items, butt
113135 < motion . div
114136 className = { cn (
115137 "pointer-events-none absolute inset-0 rounded-2xl shadow-sm" ,
116- ( isScrolled || isShellExpanded ) ? "bg-primary/50 backdrop-blur-lg " : "bg-transparent shadow-none" ,
138+ ( isScrolled || isShellExpanded ) ? "bg-primary/70 backdrop-blur-md " : "bg-transparent shadow-none" ,
117139 ) }
118140 initial = { false }
119141 animate = { {
@@ -175,15 +197,18 @@ const NavigationMobile: React.FC<NavigationMobileProps> = ({ locale, items, butt
175197 < motion . div
176198 id = "mobile-navigation-menu"
177199 key = "mobile-menu"
178- layout
179200 initial = { { opacity : 0 , y : - 4 , height : 0 } }
180- animate = { { opacity : 1 , y : 0 , height : "auto" } }
201+ animate = { { opacity : 1 , y : 0 , height : menuHeight } }
181202 exit = { { opacity : 0 , y : - 4 , height : 0 } }
182- transition = { menuTransition }
203+ transition = { {
204+ height : menuTransition ,
205+ opacity : { duration : 0.18 , ease : "easeOut" } ,
206+ y : menuTransition ,
207+ } }
183208 style = { { overflow : "hidden" } }
184209 className = "flex flex-col gap-2 px-2"
185210 >
186- < div className = "flex flex-col gap-1" >
211+ < div ref = { menuContentRef } className = "flex flex-col gap-1" >
187212 { navbarItems . map ( ( item ) => {
188213 const isOpenAcc = mobileOpenKey === item . title
189214
0 commit comments