Skip to content

Commit df3734b

Browse files
committed
fix(header): add closing animation to dropdown menu on mobile screens
1 parent f8c9e3f commit df3734b

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

src/components/sections/header.tsx

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
} from "@/components/ui/navigation-menu";
1515
import { siteConfig } from "@/lib/config";
1616
import { SiGithub, SiInstagram } from "@icons-pack/react-simple-icons";
17-
import { AnimatePresence, motion } from "framer-motion";
17+
import { motion } from "framer-motion";
1818
import { Mail, Menu } from "lucide-react";
1919
import Image from "next/image";
2020
import { useRouter } from "next/navigation";
@@ -174,33 +174,31 @@ export function Header() {
174174
</div>
175175
</div>
176176
</header>
177-
<AnimatePresence>
178-
{isOpen && (
179-
<CollapsibleContent asChild>
180-
<motion.div
181-
initial={{ opacity: 0, height: 0 }}
182-
animate={{ opacity: 1, height: "auto" }}
183-
exit={{ opacity: 0, height: 0 }}
184-
transition={{ duration: 0.3, ease: "easeInOut" }}
185-
className="absolute right-0 left-0 overflow-hidden"
186-
>
187-
<nav className="px-4 py-4 lg:px-6 bg-background/95 supports-[backdrop-filter]:bg-background/80 border-b border-b-border/40 backdrop-blur grid gap-4 text-sm">
188-
{siteConfig.mainNav.map((link) => (
189-
<div
190-
key={link.href}
191-
className="grid gap-4"
192-
>
193-
<MobileMenuGroup
194-
link={link}
195-
onLinkClick={handleCloseMenu}
196-
/>
197-
</div>
198-
))}
199-
</nav>
200-
</motion.div>
201-
</CollapsibleContent>
202-
)}
203-
</AnimatePresence>
177+
<CollapsibleContent
178+
asChild
179+
forceMount
180+
>
181+
<motion.div
182+
initial={false}
183+
animate={isOpen ? { opacity: 1, height: "auto" } : { opacity: 0, height: 0 }}
184+
transition={{ duration: 0.3, ease: "easeInOut" }}
185+
className="absolute right-0 left-0 overflow-hidden"
186+
>
187+
<nav className="px-4 py-4 lg:px-6 bg-background/95 supports-[backdrop-filter]:bg-background/80 border-b border-b-border/40 backdrop-blur grid gap-4 text-sm">
188+
{siteConfig.mainNav.map((link) => (
189+
<div
190+
key={link.href}
191+
className="grid gap-4"
192+
>
193+
<MobileMenuGroup
194+
link={link}
195+
onLinkClick={handleCloseMenu}
196+
/>
197+
</div>
198+
))}
199+
</nav>
200+
</motion.div>
201+
</CollapsibleContent>
204202
</div>
205203
</Collapsible>
206204
);

0 commit comments

Comments
 (0)