-
-
Notifications
You must be signed in to change notification settings - Fork 568
fix(mobileMenuOpen): make exit animation work #248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -7,7 +7,7 @@ import { useGithubStars } from "@/hooks/use-github-stars"; | |||||
| import { cn } from "@/lib/utils"; | ||||||
| import { formatCompactNumber } from "@/utils/format"; | ||||||
| import { ChevronRight, Menu, X } from "lucide-react"; | ||||||
| import { motion } from "motion/react"; | ||||||
| import { AnimatePresence, motion } from "motion/react"; | ||||||
| import Link from "next/link"; | ||||||
| import { ThemeToggle } from "../theme-toggle"; | ||||||
|
|
||||||
|
|
@@ -137,47 +137,49 @@ export function Header({ isScrolled, mobileMenuOpen, setMobileMenuOpen }: Header | |||||
| </div> | ||||||
| </div> | ||||||
| {/* Mobile menu */} | ||||||
| {mobileMenuOpen && ( | ||||||
| <motion.div | ||||||
| initial={{ opacity: 0, y: -20 }} | ||||||
| animate={{ opacity: 1, y: 0 }} | ||||||
| exit={{ opacity: 0, y: -20 }} | ||||||
| className="bg-background/95 absolute inset-x-0 top-16 border-b backdrop-blur-lg md:hidden" | ||||||
| > | ||||||
| <div className="container mx-auto flex flex-col gap-4 px-4 py-4"> | ||||||
| {navbarItems.map((item, i) => ( | ||||||
| <motion.a | ||||||
| key={item.label} | ||||||
| initial={{ opacity: 0, x: -10 }} | ||||||
| animate={{ opacity: 1, x: 0 }} | ||||||
| transition={{ duration: 0.2, delay: i * 0.05 }} | ||||||
| href={item.href} | ||||||
| onClick={(e) => { | ||||||
| handleScrollToSection(e); | ||||||
| setMobileMenuOpen(false); | ||||||
| }} | ||||||
| className="group relative overflow-hidden py-2 text-sm font-medium" | ||||||
| <AnimatePresence> | ||||||
| {mobileMenuOpen && ( | ||||||
| <motion.div | ||||||
| initial={{ opacity: 0, y: -20 }} | ||||||
| animate={{ opacity: 1, y: 0 }} | ||||||
| exit={{ opacity: 0, y: -20 }} | ||||||
| className="bg-background/95 absolute inset-x-0 top-16 border-b backdrop-blur-lg md:hidden" | ||||||
| > | ||||||
| <div className="container mx-auto flex flex-col gap-4 px-4 py-4"> | ||||||
| {navbarItems.map((item, i) => ( | ||||||
| <motion.a | ||||||
| key={item.label} | ||||||
| initial={{ opacity: 0, x: -10 }} | ||||||
| animate={{ opacity: 1, x: 0 }} | ||||||
| transition={{ duration: 0.2, delay: i * 0.05 }} | ||||||
| href={item.href} | ||||||
| onClick={(e) => { | ||||||
| handleScrollToSection(e); | ||||||
| setMobileMenuOpen(false); | ||||||
| }} | ||||||
| className="group relative overflow-hidden py-2 text-sm font-medium" | ||||||
| > | ||||||
| <span className="relative z-10">{item.href}</span> | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix critical bug: Display label instead of href. Line 162 displays 🔎 Apply this diff to fix the display bug:- <span className="relative z-10">{item.href}</span>
+ <span className="relative z-10">{item.label}</span>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| <span className="bg-primary absolute bottom-0 left-0 h-0.5 w-0 transition-all duration-300 group-hover:w-full"></span> | ||||||
| </motion.a> | ||||||
| ))} | ||||||
| <motion.div | ||||||
| initial={{ opacity: 0, y: 10 }} | ||||||
| animate={{ opacity: 1, y: 0 }} | ||||||
| transition={{ duration: 0.3, delay: 0.3 }} | ||||||
| className="border-border/30 mt-2 border-t pt-2" | ||||||
| > | ||||||
| <span className="relative z-10">{item.href}</span> | ||||||
| <span className="bg-primary absolute bottom-0 left-0 h-0.5 w-0 transition-all duration-300 group-hover:w-full"></span> | ||||||
| </motion.a> | ||||||
| ))} | ||||||
| <motion.div | ||||||
| initial={{ opacity: 0, y: 10 }} | ||||||
| animate={{ opacity: 1, y: 0 }} | ||||||
| transition={{ duration: 0.3, delay: 0.3 }} | ||||||
| className="border-border/30 mt-2 border-t pt-2" | ||||||
| > | ||||||
| <Link href="/editor/theme" onClick={() => setMobileMenuOpen(false)}> | ||||||
| <Button className="w-full rounded-full"> | ||||||
| Try It Now | ||||||
| <ChevronRight className="ml-2 size-4" /> | ||||||
| </Button> | ||||||
| </Link> | ||||||
| </motion.div> | ||||||
| </div> | ||||||
| </motion.div> | ||||||
| )} | ||||||
| <Link href="/editor/theme" onClick={() => setMobileMenuOpen(false)}> | ||||||
| <Button className="w-full rounded-full"> | ||||||
| Try It Now | ||||||
| <ChevronRight className="ml-2 size-4" /> | ||||||
| </Button> | ||||||
| </Link> | ||||||
| </motion.div> | ||||||
| </div> | ||||||
| </motion.div> | ||||||
| )} | ||||||
| </AnimatePresence> | ||||||
| </header> | ||||||
| ); | ||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix navigation bug: Conditionally call handleScrollToSection.
The
onClickhandler unconditionally callshandleScrollToSectionfor all menu items, but this breaks the "/pricing" link becausehandleScrollToSectioncallse.preventDefault(). The desktop version (line 79) correctly callshandleScrollToSectiononly for hash links.🔎 Apply this diff to fix the navigation bug:
onClick={(e) => { - handleScrollToSection(e); + if (item.href.startsWith("#")) { + handleScrollToSection(e); + } setMobileMenuOpen(false); }}📝 Committable suggestion
🤖 Prompt for AI Agents