LearnNewsExamplesServices
Frontmatter
id9433
titleTreeStore: Implement bulk expandAll() and collapseAll() methods
stateClosed
labels
enhancementaiarchitecturegrid
assigneestobiu
createdAtMar 10, 2026, 3:26 PM
updatedAtMar 11, 2026, 10:55 AM
githubUrlhttps://github.com/neomjs/neo/issues/9433
authortobiu
commentsCount1
parentIssue9404
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtMar 11, 2026, 10:55 AM

TreeStore: Implement bulk expandAll() and collapseAll() methods

Closed v12.1.0 enhancementaiarchitecturegrid
tobiu
tobiu commented on Mar 10, 2026, 3:26 PM

Goal

Provide expandAll() and collapseAll() methods to toggle the entire tree state efficiently without locking the UI thread.

Context

Currently, TreeStore only supports toggling individual nodes via expand(nodeId) and collapse(nodeId). Each call triggers a localized recalculation of the visible projection (_items) and a UI update. If a user needs to expand a deeply nested tree with 5,000 nodes, doing so in a loop would cause 5,000 recalculations, freezing the App Worker.

Acceptance Criteria

  • Implement expandAll() and collapseAll() in TreeStore.mjs.
  • These methods should iterate through the internal #allRecordsMap and flip the collapsed boolean on every node (silently, without triggering individual events if possible).
  • After the bulk state change, the flat _items projection must be rebuilt once from the roots.
  • Fire a single mutate or refresh event to update the UI.
  • Write a unit test in TreeStore.spec.mjs to verify bulk expanding/collapsing on a deep hierarchy.
tobiu added the enhancement label on Mar 10, 2026, 3:26 PM
tobiu added the ai label on Mar 10, 2026, 3:26 PM
tobiu added the architecture label on Mar 10, 2026, 3:26 PM
tobiu added the grid label on Mar 10, 2026, 3:26 PM
tobiu added parent issue #9404 on Mar 10, 2026, 3:27 PM
tobiu assigned to @tobiu on Mar 10, 2026, 3:29 PM
tobiu referenced in commit 219f084 - "feat(data.TreeStore): Implement bulk expandAll() and collapseAll() methods (#9433)" on Mar 11, 2026, 10:54 AM
tobiu
tobiu Mar 11, 2026, 10:54 AM

Input from Gemini 3.1 Pro:

✦ The bulk expandAll() and collapseAll() methods have been implemented in TreeStore.mjs according to the acceptance criteria.

  1. Both methods iterate through the #allRecordsMap to perform bulk state modifications.
  2. They handle both Neo.data.Record instances (via setSilent) and raw data objects (via direct property assignment) to accommodate "Turbo Mode".
  3. After the state modification, they perform a single re-projection of the _items array using collectVisibleDescendants starting from the root nodes.
  4. Instead of triggering multiple splice mutate events, they trigger a single load event passing the new _items projection, which grid.Container and other views already listen to for complete refreshes.
  5. Unit tests have been added to test/playwright/unit/data/TreeStore.spec.mjs verifying the behavior of both methods and confirming that they correctly toggle the expansion states of deeply nested trees, and a separate test was added to verify it correctly manipulates items while in Turbo Mode.

The code is committed and pushed to the repository. I'll close this ticket now.

tobiu closed this issue on Mar 11, 2026, 10:55 AM