diff --git a/.changeset/purple-gorillas-fetch.md b/.changeset/purple-gorillas-fetch.md new file mode 100644 index 000000000..684ab8486 --- /dev/null +++ b/.changeset/purple-gorillas-fetch.md @@ -0,0 +1,5 @@ +--- +'gitbook': patch +--- + +Fix table of content displaying arrow next to page with only hidden pages diff --git a/packages/gitbook/src/components/TableOfContents/PageDocumentItem.tsx b/packages/gitbook/src/components/TableOfContents/PageDocumentItem.tsx index 1c611d613..89b723cb1 100644 --- a/packages/gitbook/src/components/TableOfContents/PageDocumentItem.tsx +++ b/packages/gitbook/src/components/TableOfContents/PageDocumentItem.tsx @@ -6,7 +6,7 @@ import { } from '@gitbook/api'; import { getPageHref } from '@/lib/links'; -import { getPagePath } from '@/lib/pages'; +import { getPagePath, hasPageVisibleDescendant } from '@/lib/pages'; import { ContentRefContext } from '@/lib/references'; import { tcls } from '@/lib/tailwind'; @@ -39,7 +39,7 @@ export async function PageDocumentItem(props: { }, }} descendants={ - page.pages && page.pages.length ? ( + hasPageVisibleDescendant(page) ? ( {page.title} - {page.pages && page.pages.length ? ( + {hasPageVisibleDescendant(page) ? ( 0 && + page.pages.some( + (child) => + (child.type === RevisionPageType.Link || + child.type === RevisionPageType.Document) && + !child.hidden, + ) + ); +} + /** * Resolve the first page document in a list of pages. */