From 358e4db0e3ea924d39da0ad72920ffd6cb820459 Mon Sep 17 00:00:00 2001 From: Oleg Proskurin Date: Wed, 31 Dec 2025 16:03:46 +0700 Subject: [PATCH] fix(docs): sidebar active state not showing due to trailing slash mismatch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Next.js usePathname() returns paths with trailing slashes during static generation (e.g., /docs/) but navigation hrefs use paths without trailing slashes (e.g., /docs). The strict equality comparison was always failing. Added path normalization to strip trailing slashes before comparison. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- apps/landing/src/components/docs/layout/DocsSidebar.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/landing/src/components/docs/layout/DocsSidebar.tsx b/apps/landing/src/components/docs/layout/DocsSidebar.tsx index f33055d..aaaf960 100644 --- a/apps/landing/src/components/docs/layout/DocsSidebar.tsx +++ b/apps/landing/src/components/docs/layout/DocsSidebar.tsx @@ -80,7 +80,11 @@ export const DocsSidebar = ({ currentPath }: DocsSidebarProps) => { ); }; - const isActive = (href: string) => currentPath === href; + // Normalize path by removing trailing slash (except for root) + const normalizePath = (path: string) => (path.length > 1 && path.endsWith('/') ? path.slice(0, -1) : path); + const normalizedCurrentPath = normalizePath(currentPath); + + const isActive = (href: string) => normalizedCurrentPath === href; const isExpanded = (label: string) => expandedSections.includes(label); return (