fix(datagrid): restore applied filters when reopening a table (#1347)#1387
Merged
Conversation
Signed-off-by: Ngô Quốc Đạt <datlechin@gmail.com>
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.
What
Reopening a table now restores the filter you last applied to it, matching TablePlus. This covers closing and reopening a table within a session, and reopening after quitting and relaunching the app.
Addresses #1347 (scope settled in the issue: persist the filter on reopen, rather than adding an always-visible empty filter bar).
Root cause
Filters were already saved on apply, but restoration was broken in three stacked places:
A latent bug compounded this: the saved-filter file was keyed by the raw table name only, so the same table name collided across connections and schemas. Invisible while restoration was off; turning restoration on by default would have shown one connection's filter in another.
Changes
FilterSettingsStorage: key per (connection + database + schema + table); default panel state is now "Restore Last Filter"; a one-time migration upgrades users still on "Always Hide" and removes the old single-key files.FilterCoordinator: restore unless the user chose "Always Hide", and show the filter bar populated when a filter is restored. The restore decision is a pure function so it can be unit tested."Always Hide" still means do not restore, matching TablePlus.
Tests
FilterSettingsStorageTests: save/load round-trip, on-disk persistence across a fresh storage instance, isolation across connections, databases, and schemas, empty-clears, the new default, and the migration.FilterRestoreTests: the restore decision for each panel state.Scope and known limitations
switchDatabase, which clears filter state and rebuilds the tab list as a global operation. This pre-dates this change and affects hidden-column restoration too. Preserving per-table state across a database switch is a separate refactor of cross-database tab opening, not part of this fix. For normal sidebar reopens the tab's database matches the active database, so this path is not hit.