From dac5e9d444d747346f2ebda67df806590e281be4 Mon Sep 17 00:00:00 2001 From: Viktor Renkema Date: Wed, 21 Jan 2026 20:25:17 +0100 Subject: [PATCH] Fix logo sizing bug during navigation --- .../gitbook/src/components/PageBody/PageBody.tsx | 8 ++++---- .../components/PageBody/PreservePageLayout.tsx | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/packages/gitbook/src/components/PageBody/PageBody.tsx b/packages/gitbook/src/components/PageBody/PageBody.tsx index 8df62ca9f..41678a775 100644 --- a/packages/gitbook/src/components/PageBody/PageBody.tsx +++ b/packages/gitbook/src/components/PageBody/PageBody.tsx @@ -65,6 +65,8 @@ export function PageBody(props: { (page) => page.type !== 'document' || (page.type === 'document' && !page.hidden) ).length > 0; + const pageHasToc = page.layout.tableOfContents && hasVisibleTOCItems; + return (
- + {page.cover && page.layout.cover && page.layout.coverSize === 'hero' ? ( ) : null} diff --git a/packages/gitbook/src/components/PageBody/PreservePageLayout.tsx b/packages/gitbook/src/components/PageBody/PreservePageLayout.tsx index 834224982..016fbd2bb 100644 --- a/packages/gitbook/src/components/PageBody/PreservePageLayout.tsx +++ b/packages/gitbook/src/components/PageBody/PreservePageLayout.tsx @@ -11,9 +11,10 @@ import * as React from 'react'; * 3. Page 2 with full width block: `body:has(.site-width-wide)` is true * * This component ensures that the layout is preserved while transitioning between the 2 page states (in step 2). + * It also preserves the page TOC state (page-has-toc/page-no-toc) to prevent logo sizing issues during navigation. */ -export function PreservePageLayout(props: { siteWidthWide: boolean }) { - const { siteWidthWide } = props; +export function PreservePageLayout(props: { siteWidthWide: boolean; pageHasToc: boolean }) { + const { siteWidthWide, pageHasToc } = props; React.useLayoutEffect(() => { // We use the header as it's an element preserved between page transitions @@ -28,7 +29,15 @@ export function PreservePageLayout(props: { siteWidthWide: boolean }) { } else { header.classList.remove('site-width-wide'); } - }, [siteWidthWide]); + + if (pageHasToc) { + header.classList.add('page-has-toc'); + header.classList.remove('page-no-toc'); + } else { + header.classList.add('page-no-toc'); + header.classList.remove('page-has-toc'); + } + }, [siteWidthWide, pageHasToc]); return null; }