mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-22 06:50:15 -06:00
fix: Direct Link in Docs don't open Navigation Submenu (#3561)
Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
This commit is contained in:
@@ -289,6 +289,25 @@ interface NavigationProps extends React.ComponentPropsWithoutRef<"nav"> {
|
||||
export const Navigation = ({ isMobile, ...props }: NavigationProps) => {
|
||||
const [activeGroup, setActiveGroup] = useState<NavGroup | null>(navigation[0]);
|
||||
const [openGroups, setOpenGroups] = useState<string[]>([]);
|
||||
const pathname = usePathname();
|
||||
|
||||
useEffect(() => {
|
||||
// Check the current pathname and set the active group
|
||||
navigation.forEach((group) => {
|
||||
group.links.forEach((link) => {
|
||||
if (link.href && pathname.startsWith(link.href)) {
|
||||
setActiveGroup(group);
|
||||
} else if (link.children) {
|
||||
link.children.forEach((child) => {
|
||||
if (pathname.startsWith(child.href)) {
|
||||
setActiveGroup(group);
|
||||
setOpenGroups([`${group.title}-${link.title}`]); // Ensure parent is open
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}, [pathname]);
|
||||
|
||||
return (
|
||||
<nav {...props}>
|
||||
|
||||
Reference in New Issue
Block a user