From 9eb1e6326d37a456510dc67b14f79094f14131f9 Mon Sep 17 00:00:00 2001 From: Arush Date: Fri, 16 Aug 2024 18:53:55 -0400 Subject: [PATCH] Updating navbar to fix it --- app/components/homepage/about/index.jsx | 1 - app/components/navbar.jsx | 30 +++++++++++++------------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/app/components/homepage/about/index.jsx b/app/components/homepage/about/index.jsx index 1ffe65b..9f70f42 100644 --- a/app/components/homepage/about/index.jsx +++ b/app/components/homepage/about/index.jsx @@ -3,7 +3,6 @@ import { personalData } from "@/utils/data/personal-data"; import Image from "next/image"; - function AboutSection() { return (
diff --git a/app/components/navbar.jsx b/app/components/navbar.jsx index 2d9159a..875742f 100644 --- a/app/components/navbar.jsx +++ b/app/components/navbar.jsx @@ -10,16 +10,14 @@ function Navbar() { useEffect(() => { const handleSmoothScroll = (e) => { - const href = e.currentTarget.href; + e.preventDefault(); + const href = e.currentTarget.getAttribute('href'); const targetId = href.replace(/.*\#/, ""); + if (targetId) { - e.preventDefault(); const targetElement = document.getElementById(targetId); if (targetElement) { - targetElement.scrollIntoView({ - behavior: "smooth" - }); - // Update the URL without a page reload + targetElement.scrollIntoView({ behavior: "smooth" }); window.history.pushState({}, '', href); } } @@ -41,9 +39,7 @@ function Navbar() { ); -}; +} -export default Navbar; \ No newline at end of file +export default Navbar;