refactor(toolbar): make Active Connections a toolbar popover instead of a modal (#1350)#1386
Merged
Merged
Conversation
…ection-switcher selection (#1350)
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.
Fixes #1350.
Problem
Opening Active Connections showed a modal that dimmed the background with no visible close button, so it was unclear how to dismiss it.
Root cause
The switcher was presented as a SwiftUI
.sheet. A sheet is modal by design: it dims and blocks the parent and does not light-dismiss on click-outside, so it needs an explicit close control, which it lacked. The wrong primitive was the real problem, not a missing button.Approach
Rewrite it as a native popover anchored to the toolbar's Connection button, mirroring the existing
DatabaseSwitcher(which already does this). A SwiftUI.popoverlight-dismisses on Escape and click-outside automatically and resets its binding, so no close button is needed (this matches the macOS HIG: a popover is a transient, source-anchored view and only needs a close button for save/cancel tasks). TheCmd+Control+Cmenu path lights up the same popover with no extra work, exactly likeCmd+Kdoes for the database switcher. TablePlus, the closest native analog, uses the same pattern: a toolbar-anchored, searchable, keyboard-navigable popover with light dismiss.Changes
MainContentCoordinator: addisConnectionSwitcherShown; remove.connectionSwitcherfrom the sharedActiveSheet.MainContentCommandActions:openConnectionSwitcher()sets the flag.MainContentView: drop the.connectionSwitchersheet case.MainWindowToolbar+Buttons:ConnectionToolbarButtoncarries the.popover, bound to coordinator state.ConnectionSwitcherSheet.swiftbecomesConnectionSwitcherPopover.swift: drops the deadisPresentedbinding and.onExitCommand; adds a search field, arrow-key navigation, and Return to switch; keeps the active/saved sections, tap to activate, and Manage Connections. Ctrl+J/K is replaced by the arrow keys.ConnectionSwitcherFilter.matches(_:query:)extracted for the search.QuickSwitcherSheetstays a sheet (it is a full-content command palette, correctly modal).Tests
ConnectionSwitcherFilterTests: empty/whitespace query matches all, case-insensitive substring name match, database-name match, and non-matching query returns false.Docs
CHANGELOG under Changed.
docs/databases/overview.mdxalready described the switcher as a popover; updated it with the search, keyboard, and Escape/click-outside dismissal details so the docs match the implementation.