Frontmatter
| id | 9434 |
| title | TreeStore: Decouple clearFilters() from legacy allItems pattern |
| state | Closed |
| labels | enhancementairefactoringarchitecture |
| assignees | tobiu |
| createdAt | Mar 10, 2026, 3:26 PM |
| updatedAt | Mar 10, 2026, 4:28 PM |
| githubUrl | https://github.com/neomjs/neo/issues/9434 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | 9404 |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Mar 10, 2026, 4:28 PM |
TreeStore: Decouple clearFilters() from legacy allItems pattern
tobiu added parent issue #9404 on Mar 10, 2026, 3:27 PM
tobiu assigned to @tobiu on Mar 10, 2026, 3:29 PM

tobiu
Mar 10, 2026, 4:27 PM
Input from Gemini 3.1 Pro:
✦ I have overridden
clearFilters()inTreeStore.mjsto decouple it from the legacyallItemspattern.The new implementation simply clears
me._keptNodesand forces a full re-projection of the_itemsarray directly from the structural maps (#childrenMap), ensuring a perfectly clean recovery from a filtered state without relying on clones.Bonus: I also uncovered and fixed a subtle bug where
me.countwasn't being correctly updated afterfilter()andclearFilters()re-projections. Both methods now explicitly setme.count = me._items.length.Unit tests have been added to verify that
clearFilters()successfully restores the entire visible hierarchy and resets all states. The commit has been pushed to thedevbranch.
tobiu closed this issue on Mar 10, 2026, 4:28 PM
Goal
Refactor
clearFilters()inTreeStoreto utilize the native_keptNodesmasking logic rather than relying onCollection.Base'sallItemscloning fallback.Context
Standard
Neo.data.Storefiltering works by cloning the entire dataset into anallItemscollection so it remembers the unfiltered state. Our customTreeStore.filter()bypasses this because it relies entirely on#allRecordsMapas the ultimate source of truth, masking the projection using a_keptNodesSet. Currently, if a developer clears the filters, it might trigger the inheritedCollection.Baselogic, which expectsallItemsto exist.Acceptance Criteria
clearFilters()inTreeStore.mjs.this._keptNodes._itemsprojection (collectVisibleDescendants) from the root nodes.super.clearFilters()if that triggersallItemsmanipulation.filterevent withisFiltered: false.clearFilters()successfully restores the entire visible tree hierarchy without data loss.