Skip to content

refactor(toolbar): make Active Connections a toolbar popover instead of a modal (#1350)#1386

Merged
datlechin merged 2 commits into
mainfrom
fix/1350-connection-switcher-popover
May 22, 2026
Merged

refactor(toolbar): make Active Connections a toolbar popover instead of a modal (#1350)#1386
datlechin merged 2 commits into
mainfrom
fix/1350-connection-switcher-popover

Conversation

@datlechin
Copy link
Copy Markdown
Member

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 .popover light-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). The Cmd+Control+C menu path lights up the same popover with no extra work, exactly like Cmd+K does 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: add isConnectionSwitcherShown; remove .connectionSwitcher from the shared ActiveSheet.
  • MainContentCommandActions: openConnectionSwitcher() sets the flag.
  • MainContentView: drop the .connectionSwitcher sheet case.
  • MainWindowToolbar+Buttons: ConnectionToolbarButton carries the .popover, bound to coordinator state.
  • ConnectionSwitcherSheet.swift becomes ConnectionSwitcherPopover.swift: drops the dead isPresented binding 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.
  • Pure ConnectionSwitcherFilter.matches(_:query:) extracted for the search.

QuickSwitcherSheet stays 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.mdx already described the switcher as a popover; updated it with the search, keyboard, and Escape/click-outside dismissal details so the docs match the implementation.

@datlechin datlechin merged commit 488e065 into main May 22, 2026
1 check passed
@datlechin datlechin deleted the fix/1350-connection-switcher-popover branch May 22, 2026 13:41
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.

Active Connections modal dims the background but has no close button

1 participant