From 60df4936aa4189a28e301ebb6fc284706f7b0046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lorber?= Date: Thu, 5 Jun 2025 18:13:46 +0200 Subject: [PATCH] fix(theme): fix unability to navigate to category's page when browsing its children items (#11242) --- .../src/theme/DocSidebarItem/Category/index.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/docusaurus-theme-classic/src/theme/DocSidebarItem/Category/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocSidebarItem/Category/index.tsx index 49c384c0d1..cf29059928 100644 --- a/packages/docusaurus-theme-classic/src/theme/DocSidebarItem/Category/index.tsx +++ b/packages/docusaurus-theme-classic/src/theme/DocSidebarItem/Category/index.tsx @@ -188,7 +188,11 @@ export default function DocSidebarItemCategory({ ? (e) => { onItemClick?.(item); if (href) { - if (isActive) { + // When already on the category's page, we collapse it + // We don't use "isActive" because it would collapse the + // category even when we browse a children element + // See https://github.com/facebook/docusaurus/issues/11213 + if (isCurrentPage) { e.preventDefault(); updateCollapsed(); } else {