From 53ec8b9f2950561fffdcfe2d3263e85a938ba3c5 Mon Sep 17 00:00:00 2001 From: Nicolas Dorseuil Date: Wed, 17 Jun 2026 10:30:14 +0200 Subject: [PATCH] Enhance StructurePreview navigation by adding sectionId handling and updating state management --- .../SiteSections/SiteSectionTabs.tsx | 11 ++- .../StructurePreview/StructurePreview.tsx | 41 ++++++++- .../components/StructurePreview/state.test.ts | 87 ++++++++++++++++++- .../src/components/StructurePreview/state.ts | 45 ++++++++++ .../src/components/StructurePreview/types.ts | 7 ++ 5 files changed, 183 insertions(+), 8 deletions(-) diff --git a/packages/gitbook/src/components/SiteSections/SiteSectionTabs.tsx b/packages/gitbook/src/components/SiteSections/SiteSectionTabs.tsx index bd23fd66a..482f8d29c 100644 --- a/packages/gitbook/src/components/SiteSections/SiteSectionTabs.tsx +++ b/packages/gitbook/src/components/SiteSections/SiteSectionTabs.tsx @@ -157,6 +157,11 @@ export function SiteSectionTabs(props: { ? structureItem.url : undefined } + sectionId={ + structureItem.object === 'site-section' + ? structureItem.id + : undefined + } isActive={isActive} title={title} icon={icon ? (icon as IconName) : undefined} @@ -233,10 +238,10 @@ function useNavigationMenuViewportOffset(args: { * A tab representing a section or section group */ const SectionTab = React.forwardRef(function SectionTab( - props: { isActive: boolean; title: string; icon?: IconName; url?: string }, + props: { isActive: boolean; title: string; icon?: IconName; url?: string; sectionId?: string }, ref: React.Ref ) { - const { isActive, title, icon, url, ...rest } = props; + const { isActive, title, icon, url, sectionId, ...rest } = props; const isGroup = url === undefined; return (