diff --git a/apps/studio/components/layouts/OrganizationLayout.tsx b/apps/studio/components/layouts/OrganizationLayout.tsx index 2427f016f728a..395ad4a30569f 100644 --- a/apps/studio/components/layouts/OrganizationLayout.tsx +++ b/apps/studio/components/layouts/OrganizationLayout.tsx @@ -9,10 +9,12 @@ import { ScaffoldContainer, ScaffoldDivider, ScaffoldHeader, ScaffoldTitle } fro import SettingsLayout from './SettingsLayout/SettingsLayout' import Link from 'next/link' import { useOrgSubscriptionQuery } from '../../data/subscriptions/org-subscription-query' +import { useCurrentPath } from 'hooks/misc/useCurrentPath' const OrganizationLayout = ({ children }: PropsWithChildren<{}>) => { const selectedOrganization = useSelectedOrganization() const router = useRouter() + const currentPath = useCurrentPath() const { slug } = useParams() const invoicesEnabledOnProfileLevel = useIsFeatureEnabled('billing:invoices') @@ -80,7 +82,7 @@ const OrganizationLayout = ({ children }: PropsWithChildren<{}>) => { {filteredNavMenuItems.map((item) => ( - + {item.label} ))} diff --git a/apps/studio/hooks/misc/useCurrentPath.tsx b/apps/studio/hooks/misc/useCurrentPath.tsx new file mode 100644 index 0000000000000..300ba62df245c --- /dev/null +++ b/apps/studio/hooks/misc/useCurrentPath.tsx @@ -0,0 +1,14 @@ +import { useRouter } from 'next/router' + +export const useCurrentPath = () => { + const router = useRouter() + + if (!router.isReady) { + return '' + } + + const pathWithQuery = router.asPath + const currentPath = pathWithQuery.split('?')[0] + + return currentPath +} diff --git a/packages/ui/src/components/NavMenu/index.tsx b/packages/ui/src/components/NavMenu/index.tsx index 468a267ee1c40..fa2ba5e26be4d 100644 --- a/packages/ui/src/components/NavMenu/index.tsx +++ b/packages/ui/src/components/NavMenu/index.tsx @@ -20,24 +20,26 @@ export const NavMenu = forwardRef( } ) -export const NavMenuItem = ({ - children, - className, - active, - ...props -}: PropsWithChildren<{ - className?: string - active: boolean -}>) => ( -
  • - {children} -
  • +export const NavMenuItem = forwardRef( + ({ + children, + className, + active, + ...props + }: PropsWithChildren<{ + className?: string + active: boolean + }>) => ( +
  • + {children} +
  • + ) )