Closed JaznanOfficial closed 5 months ago
This issue has been automatically closed because it received no activity for a while. If you think it was closed by accident, please leave a comment. Thank you.
For anyone with such a problem just wrap each link with this tag : <SheetClose asChild>link or whatever</SheetClose>
It makes clicking on a link just close the Sheet.
For anyone with such a problem just wrap each link with this tag :
<SheetClose asChild>link or whatever</SheetClose>
It makes clicking on a link just close the Sheet.
Thanks it worked for me
If anyone has a problem with handling the opening and closing of the sidebar, there is a hook useSidebar
that allows you to control this without interfering with the sidebar component
const { openMobile, setOpenMobile } = useSidebar();
I used sheet as mobile sidebar. where I have routes to navigate other pages. and some routes contains hash routing like /#testimonials. when I open sheet and click Link component of next.js it's perfectly navigating me to that route and special block connected using hash. but when am clicking which rendering a close button, then hash routing not working. and it's throw me at the top of the page. see it's navigating other page perfectly but preventing only hash routing and throw at the top of the page. below is my code.
` "use client";
import { useEffect, useRef, useState } from "react"; import { Menu, MenuIcon, MinusIcon, MoonIcon, SunIcon } from "lucide-react";
import { Button } from "@/components/ui/button"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { cn, contactItems, routes } from "@/lib/utils"; import { Sheet, SheetClose, SheetContent, SheetTrigger } from "@/components/ui/sheet";
interface SideNavbarProps { themeHandler: () => void; }
const SideNavbar: React.FC = ({ themeHandler }) => {
const pathname = usePathname();
const sheetCloseRef = useRef(null);
const [isMounted, setIsMounted] = useState(false);
useEffect(() => {
setIsMounted(true);
}, []);
};
export default SideNavbar; `
and
`export const routes = [ { link: "/", name: "Home", }, { link: "/#about", name: "About", }, { link: "/#skills", name: "Skills", }, { link: "/#services", name: "Services", }, { link: "/#testimonials", name: "Testimonials", }, { link: "/#contact", name: "Contact", }, { link: "/projects", name: "Projects", },
];`
screen-capture.webm