Frontmatter
| id | 8887 |
| title | fix: Collection.filter() should not clear allItems when restoring unfiltered state |
| state | Closed |
| labels | bugairegression |
| assignees | tobiu |
| createdAt | Jan 26, 2026, 8:54 PM |
| updatedAt | Jan 26, 2026, 8:56 PM |
| githubUrl | https://github.com/neomjs/neo/issues/8887 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Jan 26, 2026, 8:56 PM |
fix: Collection.filter() should not clear allItems when restoring unfiltered state
tobiu assigned to @tobiu on Jan 26, 2026, 8:56 PM

tobiu
Jan 26, 2026, 8:56 PM
Input from Gemini 3 Pro:
✦ I have resolved the regression.
Fix Details: In
src/collection/Base.mjs, thefilter()method was updated. Instead of callingme.clearSilent()(which now recursively clearsallItemsdue to the fix for #8886), I have inlined the logic to clear only the local_itemsandmapalong with resettinginitialIndexCounter.This ensures that when
filter()restores the full dataset (un-filtering), it reads from the intactallItemscollection instead of wiping it out first.Verification:
npm run test-unit -- collection/Base(The failing test) -> PASSEDnpm run test-unit -- collection/MassiveData(The original fix verification) -> PASSED
tobiu closed this issue on Jan 26, 2026, 8:56 PM
The recent fix for #8886 introduced a recursive
clearSilent()that implicitly clearsallItems. However,Collection.filter()usesclearSilent()internally when restoring the full dataset (when all filters are disabled). This causesallItemsto be wiped out, resulting in data loss when un-filtering.Resolution: Replace the
clearSilent()call insrc/collection/Base.mjs'sfilter()method with manual cleanup that only targets the current view's_itemsandmap, leavingallItemsintact.