From c9108f530c87a3a39d6a5250db245a07c33c9942 Mon Sep 17 00:00:00 2001 From: Max Kotlan Date: Mon, 10 Jan 2022 13:14:46 -0500 Subject: [PATCH] mobile menu fix animation close on page load (#652) --- ui/component/sideNavigation/view.jsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ui/component/sideNavigation/view.jsx b/ui/component/sideNavigation/view.jsx index 19239c10c..4fbe50b19 100644 --- a/ui/component/sideNavigation/view.jsx +++ b/ui/component/sideNavigation/view.jsx @@ -221,14 +221,17 @@ function SideNavigation(props: Props) { const isAbsolute = isOnFilePage || isMediumScreen; const isMobile = useIsMobile(); - const menuCanCloseCompletely = isOnFilePage || isMobile; + const [menuInitialized, setMenuInitialized] = React.useState(false); + + const menuCanCloseCompletely = (isOnFilePage && !isMobile) || (isMobile && menuInitialized); const hideMenuFromView = menuCanCloseCompletely && !sidebarOpen; const [canDisposeMenu, setCanDisposeMenu] = React.useState(false); React.useEffect(() => { - if (hideMenuFromView) { + if (hideMenuFromView || !menuInitialized) { const handler = setTimeout(() => { + setMenuInitialized(true); setCanDisposeMenu(true); }, 250); return () => { @@ -237,7 +240,7 @@ function SideNavigation(props: Props) { } else { setCanDisposeMenu(false); } - }, [hideMenuFromView]); + }, [hideMenuFromView, menuInitialized]); const shouldRenderLargeMenu = menuCanCloseCompletely || sidebarOpen;