Skip to content

Commit 71280a5

Browse files
committed
fixes for state glitch on top level links
1 parent e904a0c commit 71280a5

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/components/MobileSideBarMenu/Content.jsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,31 @@ const MobileSideBarMenuContents = ({ className, onClick, onClose, sidebar, path,
101101
let itemHref = item.href || (item.customProps && item.customProps.href);
102102

103103
if (itemHref) {
104-
// Fix URLs for main menu items - add /docs/ prefix if missing and handle localization
105-
// Use shouldShowMainMenu() instead of showTopLevel to catch invalid pages too
106-
if (shouldShowMainMenu() && itemHref && !itemHref.startsWith('/docs/') && !itemHref.startsWith('http')) {
104+
// Determine if we should add /docs/ prefix
105+
// This happens when we're in the main menu OR when the current path suggests we're in docs
106+
const isInMainMenu = shouldShowMainMenu();
107+
const isDocsContext = location.pathname.startsWith('/docs/');
108+
const shouldAddDocsPrefix = (isInMainMenu || isDocsContext) &&
109+
!itemHref.startsWith('/docs/') &&
110+
!itemHref.startsWith('http');
111+
112+
console.log('Navigation debug:', {
113+
item: item.label,
114+
originalHref: itemHref,
115+
isInMainMenu,
116+
isDocsContext,
117+
shouldAddDocsPrefix,
118+
currentPath: location.pathname
119+
});
120+
121+
if (shouldAddDocsPrefix) {
107122
const currentLocale = getCurrentLocale();
108123
if (currentLocale !== 'en') {
109124
itemHref = `/docs/${currentLocale}${itemHref}`;
110125
} else {
111126
itemHref = `/docs${itemHref}`;
112127
}
128+
console.log('Fixed href:', itemHref);
113129
}
114130

115131
// Navigate to the href

0 commit comments

Comments
 (0)