From 6da42fac20c73567ceb235e1bcbd121f82f53bf8 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 19 Dec 2025 23:32:58 +0200 Subject: [PATCH] feat(right_pane_widget): handle zero headings --- apps/client/src/translations/en/translation.json | 3 ++- apps/client/src/widgets/sidebar/TableOfContents.tsx | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json index fc3bd5879..458ea6b0c 100644 --- a/apps/client/src/translations/en/translation.json +++ b/apps/client/src/translations/en/translation.json @@ -1796,7 +1796,8 @@ }, "toc": { "table_of_contents": "Table of Contents", - "options": "Options" + "options": "Options", + "no_headings": "No headings." }, "watched_file_update_status": { "file_last_modified": "File has been last modified on .", diff --git a/apps/client/src/widgets/sidebar/TableOfContents.tsx b/apps/client/src/widgets/sidebar/TableOfContents.tsx index 48c5217e9..b58c2d8c4 100644 --- a/apps/client/src/widgets/sidebar/TableOfContents.tsx +++ b/apps/client/src/widgets/sidebar/TableOfContents.tsx @@ -40,9 +40,13 @@ function AbstractTableOfContents({ headings, scrollToHeadi const nestedHeadings = buildHeadingTree(headings); return ( -
    - {nestedHeadings.map(heading => )} -
+ {nestedHeadings.length > 0 ? ( +
    + {nestedHeadings.map(heading => )} +
+ ) : ( +
{t("toc.no_headings")}
+ )}
); }