From 779f57902ed8f1e5758bd2174eada0ae204d9f8e Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Fri, 31 Jul 2026 15:02:22 +0800 Subject: [PATCH] fix(skills): hide main navigation on detail pages --- .../main-nav/__tests__/layout.spec.tsx | 25 +++++++++++++++++++ web/app/components/main-nav/routes.ts | 15 ++++++++--- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/web/app/components/main-nav/__tests__/layout.spec.tsx b/web/app/components/main-nav/__tests__/layout.spec.tsx index 4937f4e9270..cd8432b762c 100644 --- a/web/app/components/main-nav/__tests__/layout.spec.tsx +++ b/web/app/components/main-nav/__tests__/layout.spec.tsx @@ -196,6 +196,31 @@ describe('MainNavLayout', () => { expect(screen.getByRole('main')).toHaveTextContent('new knowledge detail') }) + it('hides the global main nav on a skill detail route', () => { + ;(usePathname as Mock).mockReturnValue('/skills/skill-1') + + render( + +
skill detail
+
, + ) + + expect(screen.queryByTestId('main-nav')).not.toBeInTheDocument() + expect(screen.getByRole('main')).toHaveTextContent('skill detail') + }) + + it('keeps the global main nav on the skills collection route', () => { + ;(usePathname as Mock).mockReturnValue('/skills') + + render( + +
skills collection
+
, + ) + + expect(screen.getByTestId('main-nav')).toBeInTheDocument() + }) + it.each([ '/datasets/create', '/datasets/new/create', diff --git a/web/app/components/main-nav/routes.ts b/web/app/components/main-nav/routes.ts index 2aaed683ace..a3506c3aecf 100644 --- a/web/app/components/main-nav/routes.ts +++ b/web/app/components/main-nav/routes.ts @@ -151,14 +151,21 @@ function isDatasetDetailPathname(pathname: string) { return true } +function isSkillDetailPathname(pathname: string) { + const [section, skillId] = pathname.split('/').filter(Boolean) + + return section === 'skills' && !!skillId +} + export function shouldHideMainNavigation(pathname: string) { const [section, namespace, knowledgeSpaceId] = pathname.split('/').filter(Boolean) return ( - section === 'datasets' && - namespace === 'new' && - !!knowledgeSpaceId && - knowledgeSpaceId !== 'create' + (section === 'datasets' && + namespace === 'new' && + !!knowledgeSpaceId && + knowledgeSpaceId !== 'create') || + isSkillDetailPathname(pathname) ) }