Skip to content

Commit d76446d

Browse files
fix : mobile-navbar
Signed-off-by: greedy-wudpeckr <mudituiet@gmail.com>
1 parent 967ebfa commit d76446d

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

frontend/src/components/HomeComponents/Navbar/NavbarMobile.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,23 @@ export const NavbarMobile = (
106106
props.setIsOpen(false);
107107
};
108108

109+
const handleNavClick = (
110+
e: React.MouseEvent<HTMLAnchorElement>,
111+
href: string
112+
) => {
113+
e.preventDefault();
114+
props.setIsOpen(false);
115+
116+
// Wait for sheet to close, then scroll
117+
setTimeout(() => {
118+
const targetId = href.replace('#', '');
119+
const element = document.getElementById(targetId);
120+
if (element) {
121+
element.scrollIntoView({ behavior: 'smooth', block: 'start' });
122+
}
123+
}, 300);
124+
};
125+
109126
return (
110127
<span className="flex md:hidden">
111128
<ModeToggle />
@@ -132,7 +149,7 @@ export const NavbarMobile = (
132149
rel="noreferrer noopener"
133150
key={label}
134151
href={href}
135-
onClick={() => props.setIsOpen(false)}
152+
onClick={(e) => handleNavClick(e, href)}
136153
className={buttonVariants({ variant: 'ghost' })}
137154
>
138155
{label}

0 commit comments

Comments
 (0)