feat(editor): auto-close left sidebar when TOC is empty#651
Merged
backnotprop merged 2 commits intomainfrom May 2, 2026
Merged
feat(editor): auto-close left sidebar when TOC is empty#651backnotprop merged 2 commits intomainfrom
backnotprop merged 2 commits intomainfrom
Conversation
When the parsed document has no level 1-3 headings (common for annotate and annotate-last sessions), keep the sidebar closed regardless of the "Auto-open Sidebar" preference. The collapsed flag strip stays available so users can still open it manually; manual re-open is not overridden until the document changes again.
Adding hasTocEntries to the tocEnabled sync effect's dep array while
the const itself was declared 300+ lines later threw a TDZ error at
render ("Cannot access 'Pe' before initialization" in the minified
bundle). Move the useMemo above the effects so dep-array evaluation
sees an initialized binding.
HeikoAtGitHub
pushed a commit
to HeikoAtGitHub/plannotator
that referenced
this pull request
May 3, 2026
) * feat(editor): auto-close left sidebar when TOC is empty When the parsed document has no level 1-3 headings (common for annotate and annotate-last sessions), keep the sidebar closed regardless of the "Auto-open Sidebar" preference. The collapsed flag strip stays available so users can still open it manually; manual re-open is not overridden until the document changes again. * fix(editor): hoist hasTocEntries above the effects that read it Adding hasTocEntries to the tocEnabled sync effect's dep array while the const itself was declared 300+ lines later threw a TDZ error at render ("Cannot access 'Pe' before initialization" in the minified bundle). Move the useMemo above the effects so dep-array evaluation sees an initialized binding.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
annotate/annotate-lastsessions and structureless plans), keep the left sidebar closed regardless of the "Auto-open Sidebar" preference.annotate-folder).archivestill forces the Archive tab open,annotate-folderstill forces Files.Implementation
In
packages/editor/App.tsx:hasTocEntriesfromblocksusing the samelevel <= 3rule asbuildTocHierarchy.tocEnabledsync effect: onlysidebar.open('toc')whenhasTocEntriesis true. Closing on toggle-off is preserved.[blocks, hasTocEntries]that closes the sidebar when blocks parse with no TOC entries and the active tab is TOC. Intentionally does not depend on sidebar state, so a manual re-open sticks until the document changes.Test plan
tocEnabled(unchanged).annotate/annotate-laston a heading-less doc: sidebar stays closed.annotate-folder: switching between files with/without headings keeps Files tab open; switching to TOC tab on a heading-less file closes the sidebar.archivemode: Archive tab still force-opens.