From 03fdb846cdde51efa795b243490c61a290526bfc Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 3 Mar 2022 21:46:53 -0800 Subject: [PATCH] fix: Hide TOC toggle on publicly shared links if there are no headings in the document (#3172) closes #3006 --- app/scenes/Document/components/Document.tsx | 5 ++++- app/scenes/Document/components/Header.tsx | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/scenes/Document/components/Document.tsx b/app/scenes/Document/components/Document.tsx index 83ab850f9..881db17ec 100644 --- a/app/scenes/Document/components/Document.tsx +++ b/app/scenes/Document/components/Document.tsx @@ -416,8 +416,10 @@ class DocumentScene extends React.Component { this.editor.current.getHeadings() : []; + const hasHeadings = headings.length > 0; const showContents = - ui.tocVisible && (readOnly || team?.collaborativeEditing); + ui.tocVisible && + ((readOnly && hasHeadings) || team?.collaborativeEditing); const collaborativeEditing = team?.collaborativeEditing && !document.isArchived && @@ -509,6 +511,7 @@ class DocumentScene extends React.Component { )}
- {toc} + {documentHasHeadings ? toc : null} ) }