Skip to content

fix(datagrid): persist cleared filters so they don't return on reopen (#1347)#1395

Merged
datlechin merged 4 commits into
mainfrom
fix/1347-persist-cleared-filter
May 22, 2026
Merged

fix(datagrid): persist cleared filters so they don't return on reopen (#1347)#1395
datlechin merged 4 commits into
mainfrom
fix/1347-persist-cleared-filter

Conversation

@datlechin

Copy link
Copy Markdown
Member

Follow-up to #1387 (restore applied filters on reopen).

Bug

Apply a filter, then Unset (clear) it, then close the table tab and reopen it: the old filter comes back. Clearing isn't remembered.

Root cause

#1387 made filter persistence asymmetric. The apply path persists:

  • FilterCoordinator.applyFiltersAndReload() calls saveLastFilters(for:).

The clear path does not:

  • FilterCoordinator.clearFiltersAndReload() rebuilds the base query and reloads but never touches FilterSettingsStorage.

So the saved filter file is left on disk when you clear, and restoreLastFilters brings it back on reopen.

Fix

Make the user-clear path symmetric with apply: clearFiltersAndReload() now calls a new clearLastFilters(for:) helper, which removes the saved filter for that table (FilterSettingsStorage.clearLastFilters).

This is deliberately placed in clearFiltersAndReload() (the user-initiated Unset), not in clearFilterState(). clearFilterState() is an internal UI-state reset used during tab switching/replacement, where the outgoing table's filters are intentionally saved first; clearing persistence there would wrongly delete a filter the user wants restored.

Tests

FilterSettingsStorageTests: added a test that after clearLastFilters, loadLastFilters returns empty (the contract the fix relies on). The pure restore-decision function and storage round-trip from #1387 are unchanged. FilterCoordinator reaches storage via .shared with no DI seam (as #1387 left it), so the coordinator wiring mirrors the proven save path rather than adding a DI refactor.

Docs / CHANGELOG

Folded into the existing unreleased #1347 entry (the restore feature is still unreleased, so this isn't a separate "Fixed" line). Filtering docs note that clearing with Unset is remembered.

@datlechin datlechin merged commit 3b2ed6d into main May 22, 2026
2 checks passed
@datlechin datlechin deleted the fix/1347-persist-cleared-filter branch May 22, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant