From 8f0c55808d6b3d14d35cbdbcfbf6b8a35f7aa54f Mon Sep 17 00:00:00 2001 From: DivyanshuLohani <59534359+DivyanshuLohani@users.noreply.github.com> Date: Tue, 15 Oct 2024 07:01:24 +0530 Subject: [PATCH] fix: navigation active link issue (#3459) Co-authored-by: Piyush Gupta Co-authored-by: Johannes --- apps/docs/app/global/access-roles/page.mdx | 8 ++++---- apps/docs/components/Navigation.tsx | 23 ++++++++++++++++++---- apps/web/playwright/organization.spec.ts | 4 ++-- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/apps/docs/app/global/access-roles/page.mdx b/apps/docs/app/global/access-roles/page.mdx index edacf86469..268770519d 100644 --- a/apps/docs/app/global/access-roles/page.mdx +++ b/apps/docs/app/global/access-roles/page.mdx @@ -87,11 +87,11 @@ There are two ways to invite organization members: One by one or in bulk. className="max-w-full rounded-lg sm:max-w-3xl" /> -2. Click on the `Add Member` button: +2. Click on the `Add member` button: @@ -123,11 +123,11 @@ Formbricks sends an email to the organization member with an invitation link. Th className="max-w-full rounded-lg sm:max-w-3xl" /> -2. Click on the `Add Member` button: +2. Click on the `Add member` button: diff --git a/apps/docs/components/Navigation.tsx b/apps/docs/components/Navigation.tsx index 2d17f8402a..e31bb5183e 100644 --- a/apps/docs/components/Navigation.tsx +++ b/apps/docs/components/Navigation.tsx @@ -7,7 +7,7 @@ import { AnimatePresence, motion, useIsPresent } from "framer-motion"; import { ChevronDownIcon, ChevronUpIcon } from "lucide-react"; import Link from "next/link"; import { usePathname } from "next/navigation"; -import { useRef, useState } from "react"; +import { useEffect, useRef, useState } from "react"; import { Button } from "./Button"; import { useIsInsideMobileNavigation } from "./MobileNavigation"; import { useSectionStore } from "./SectionProvider"; @@ -158,7 +158,11 @@ const NavigationGroup = ({ }) => { const isInsideMobileNavigation = useIsInsideMobileNavigation(); const pathname = usePathname(); - const isActiveGroup = activeGroup?.title === group.title; + const [isActiveGroup, setIsActiveGroup] = useState(false); + + useEffect(() => { + setIsActiveGroup(activeGroup?.title === group.title); + }, [activeGroup?.title, group.title]); const toggleParentTitle = (title: string) => { if (openGroups.includes(title)) { @@ -171,6 +175,13 @@ const NavigationGroup = ({ const isParentOpen = (title: string) => openGroups.includes(title); + const sortedLinks = group.links.map((link) => { + if (link.children) { + link.children.sort((a, b) => a.title.localeCompare(b.title)); + } + return link; + }); + return (
  • @@ -185,8 +196,12 @@ const NavigationGroup = ({ {isActiveGroup && }
      - {group.links.map((link) => ( - + {sortedLinks.map((link) => ( + setIsActiveGroup(true)}> {link.href ? ( { await page.locator('[data-testid="members-loading-card"]:first-child').waitFor({ state: "hidden" }); // Add member button - await expect(page.getByRole("button", { name: "Add Member" })).toBeVisible(); - await page.getByRole("button", { name: "Add Member" }).click(); + await expect(page.getByRole("button", { name: "Add member" })).toBeVisible(); + await page.getByRole("button", { name: "Add member" }).click(); // Fill the member name and email form await expect(page.getByLabel("Email")).toBeVisible();