Files
outline/app/components
Tom Moor bac2b01abd perf: Refactor sidebar expanded state (#12215)
* 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>
2026-04-29 19:28:53 -04:00
..
2026-04-18 15:12:57 -04:00
2026-04-18 15:12:57 -04:00
2026-04-15 21:26:43 -04:00
2025-12-23 11:53:41 -05:00
2026-04-18 15:12:57 -04:00
2026-04-18 15:12:57 -04:00
2023-02-25 12:03:05 -08:00
2026-04-03 19:50:50 -04:00
2026-02-20 18:53:00 -05:00
2024-11-02 10:58:03 -07:00
2025-03-15 15:06:12 -07:00
2026-04-20 19:34:16 -04:00
2026-04-18 15:12:57 -04:00
2026-04-18 15:12:57 -04:00
2026-04-20 19:34:16 -04:00
2023-09-23 14:31:55 -04:00
2026-04-18 15:12:57 -04:00
2026-04-20 19:34:16 -04:00
2026-02-20 18:53:00 -05:00
2026-04-18 15:12:57 -04:00