fix(datagrid): persist cleared filters so they don't return on reopen (#1347)#1395
Merged
Conversation
…don't return on reopen (#1347)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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()callssaveLastFilters(for:).The clear path does not:
FilterCoordinator.clearFiltersAndReload()rebuilds the base query and reloads but never touchesFilterSettingsStorage.So the saved filter file is left on disk when you clear, and
restoreLastFiltersbrings it back on reopen.Fix
Make the user-clear path symmetric with apply:
clearFiltersAndReload()now calls a newclearLastFilters(for:)helper, which removes the saved filter for that table (FilterSettingsStorage.clearLastFilters).This is deliberately placed in
clearFiltersAndReload()(the user-initiated Unset), not inclearFilterState().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 afterclearLastFilters,loadLastFiltersreturns empty (the contract the fix relies on). The pure restore-decision function and storage round-trip from #1387 are unchanged.FilterCoordinatorreaches storage via.sharedwith 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.