Skip to content

refactor(toolbar): use native NSSearchField in the connection and database switchers#1389

Merged
datlechin merged 2 commits into
mainfrom
fix/1350-native-search-field
May 22, 2026
Merged

refactor(toolbar): use native NSSearchField in the connection and database switchers#1389
datlechin merged 2 commits into
mainfrom
fix/1350-native-search-field

Conversation

@datlechin

Copy link
Copy Markdown
Member

Follow-up to #1386 (Active Connections popover).

Why

Both the connection switcher and the database switcher hand-rolled their search field: an HStack with a magnifying-glass SF Symbol, a plain TextField, a custom rounded background, and a manual clear button. That mimics a search field but is not the native control, so it misses the real NSSearchField bezel, the system clear button, the search-field accessibility role, and native Escape-to-clear.

The codebase already has a native wrapper, NativeSearchField (NSSearchField via NSViewRepresentable, used by the sidebar). Both switchers should use it.

Change

Replace the custom search HStack in ConnectionSwitcherPopover and DatabaseSwitcherPopover with NativeSearchField, wiring onMoveUp/onMoveDown/onSubmit to the existing navigation and commit actions. This removes the per-view @FocusState, the manual .onKeyPress arrow/Return/Escape handlers, and the hand-built clear button. NativeSearchField already handles arrow and Return via the field's doCommandBy, and on Escape clears the field when it has text and otherwise lets the event through so the popover dismisses.

Net -113 lines across the two views.

Behavior

Same interaction, now native: type to filter, arrow keys to move, Return to switch, Escape to clear then dismiss, plus the standard search-field clear button. The database switcher keeps its list primaryAction for Return when the list itself has focus.

No CHANGELOG or docs change: the user-facing behavior is unchanged, this is an internal move to the native control.

@datlechin datlechin force-pushed the fix/1350-native-search-field branch from a014acc to 27aa58e Compare May 22, 2026 14:43
@datlechin datlechin merged commit de8142a into main May 22, 2026
2 checks passed
@datlechin datlechin deleted the fix/1350-native-search-field branch May 25, 2026 02:34
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.

1 participant