fix(sidebar): keep the table filter when opening another tab#1715
Merged
Conversation
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.
Problem
Filter the sidebar table list, open a table, then open a second table tab: the new tab's sidebar shows no filter, so the filter text and the filtered list appear lost.
Root cause
The sidebar filter text (
searchText,favoritesSearchText) lived inWindowSidebarState, whichMainContentCoordinatorcreates fresh per window tab. TablePro tabs are native NSWindow tabs, so opening a second table tab spins up a new coordinator with an empty filter. The rest of the connection-scoped sidebar state (layout, selected tab, database filter) already lives inSharedSidebarState; the filter text was the outlier.Fix
Move the two filter-text fields from
WindowSidebarStatetoSharedSidebarState, the per-connection registry shared across all tabs/windows of a connection. Table selection (selectedTables) and tree-expansion state stay window-scoped, so the #1313 Cmd+T focus regression is untouched.SharedSidebarStategainssearchText/favoritesSearchText;WindowSidebarStatedrops them.SidebarContainerViewControllerreads/writes/observes the filter on the shared state and no longer needs the window state.MainSplitViewControllercallers updated.SidebarView/FavoritesTabViewread the filter from the shared state.Tests
SharedSidebarStateTests(persist across tabs of the same connection, independent across connections). Kept theselectedTablesper-window test that guards SQLite new query tab auto jump to other tab #1313.swiftlint lint --strictclean on changed files.@MainActorisolation error inDatabaseTreeMetadataServiceTests, so the suite was not run locally. CI on the stable toolchain should run it.