LearnNewsExamplesServices
Frontmatter
id8887
titlefix: Collection.filter() should not clear allItems when restoring unfiltered state
stateClosed
labels
bugairegression
assigneestobiu
createdAtJan 26, 2026, 8:54 PM
updatedAtJan 26, 2026, 8:56 PM
githubUrlhttps://github.com/neomjs/neo/issues/8887
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJan 26, 2026, 8:56 PM

fix: Collection.filter() should not clear allItems when restoring unfiltered state

Closed v11.24.0 bugairegression
tobiu
tobiu commented on Jan 26, 2026, 8:54 PM

The recent fix for #8886 introduced a recursive clearSilent() that implicitly clears allItems. However, Collection.filter() uses clearSilent() internally when restoring the full dataset (when all filters are disabled). This causes allItems to be wiped out, resulting in data loss when un-filtering.

Resolution: Replace the clearSilent() call in src/collection/Base.mjs's filter() method with manual cleanup that only targets the current view's _items and map, leaving allItems intact.

tobiu added the bug label on Jan 26, 2026, 8:54 PM
tobiu added the ai label on Jan 26, 2026, 8:54 PM
tobiu added the regression label on Jan 26, 2026, 8:54 PM
tobiu referenced in commit 6b8c1b7 - "fix: Collection.filter() should not clear allItems when restoring unfiltered state (#8887)" on Jan 26, 2026, 8:56 PM
tobiu assigned to @tobiu on Jan 26, 2026, 8:56 PM
tobiu
tobiu Jan 26, 2026, 8:56 PM

Input from Gemini 3 Pro:

✦ I have resolved the regression.

Fix Details: In src/collection/Base.mjs, the filter() method was updated. Instead of calling me.clearSilent() (which now recursively clears allItems due to the fix for #8886), I have inlined the logic to clear only the local _items and map along with resetting initialIndexCounter.

This ensures that when filter() restores the full dataset (un-filtering), it reads from the intact allItems collection instead of wiping it out first.

Verification:

  • npm run test-unit -- collection/Base (The failing test) -> PASSED
  • npm run test-unit -- collection/MassiveData (The original fix verification) -> PASSED
tobiu closed this issue on Jan 26, 2026, 8:56 PM