mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
bac2b01abd
* fix: centralize sidebar expansion state to eliminate O(N²) tree traversals Each DocumentLink previously traversed the full collection tree independently to determine whether to auto-expand (pathToDocument / descendants), which is O(N) per row and quadratic overall. With thousands of documents this makes the sidebar unusable. Replaces per-node expansion state with a single MobX-backed SidebarExpansionState per tree root. The ObservableSet ensures only the toggled node re-renders. Alt-click cascade, auto-expand on navigation, and drag-to-reparent expansion all go through the same centralized state instead of the per-node SidebarDisclosureContext relay. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor: move SidebarExpansionContext alongside other sidebar contexts Rename hooks/useSidebarExpansion.ts to components/SidebarExpansionContext.ts to match the convention of SidebarContext.ts and SidebarDisclosureContext.ts. The context is now the default export with hooks as named exports. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: scope sidebar expansion to its own tree and restore alt-click cascade `useSidebarExpansionState` was unconditionally adding the active document id to every per-tree expansion set, which made `SharedWithMeLink` auto- expand whenever the user navigated anywhere in the matching sidebar context. `computeAncestorPath` now includes the target when found and returns empty when absent, so the hook only expands ids that actually belong to its tree. Also restores alt-click cascade for `StarredDocumentLink` and `SharedWithMeLink`: the parents still broadcast disclosure events but `DocumentLink` no longer listens, so nested children weren't expanded. `StarredDocumentLink` now subscribes via `useSidebarDisclosure` (mirroring `CollectionLinkChildren`), and `SharedWithMeLink` calls `expansion.expandAll`/`collapseAll` directly on alt-click. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * fix: collapse expanded nodes when children are removed and deduplicate shared expansion provider Restores the effect that collapses a node in the expansion state when it no longer has children, preventing the reorder drop logic from treating leaf nodes as expanded containers. Also removes the redundant SidebarExpansionContext.Provider from SharedCollectionLink since the parent SharedSidebar already provides one. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>