fix(datagrid): focus the switcher search field when a filter input is being edited#1596
Merged
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.
Fixes #1575
Problem
With a column filter input focused, opening the connection switcher left the cursor stuck in the filter field. Typing never reached the popover's search field.
Root cause
FilterValueTextField's coordinator re-assertedmakeFirstResponderon the main window on every SwiftUI update pass whilefocusedFilterIdmatched. The switcher popover lives in a separate window, so AppKit never resigned the filter field,focusedFilterIdnever cleared, and the filter field kept reclaiming focus against the popover. The search field's own claim was a one-shotDispatchQueue.main.asyncfired frommakeNSViewwhilefield.windowwas still nil, and it never made the popover window key, so key events stayed routed to the main window.Fix
FilterValueTextField: newFilterFocusStatevalue type. Focus is claimed once per transition instead of re-asserted by polling, and released when the main window resigns key (NSWindow.didResignKeyNotification). The filter field no longer fights any popover, panel, or sheet.NativeSearchField: thefocusOnAppearclaim moved toviewDidMoveToWindow, where the window is guaranteed non-nil, and now callsmakeKey()so key events route to the popover window. This also hardens the database switcher and quick switcher, which share this component.MainContentCommandActions:openConnectionSwitcher()andopenDatabaseSwitcher()callmakeFirstResponder(nil)first, the documented way to end editing. Pending filter text is committed, not discarded.This matches the platform contract documented by
NSSearchToolbarItem.beginSearchInteraction()("moves the keyboard focus to the search field") and the HIG guidance to start dedicated search areas focused.Tests
FilterFocusStateTestscovers every transition of the focus state machine, including the exact regression: a repeated request must not re-claim focus. 7/7 passed.FilterValueTextFieldTestsstill pass (28/28).swiftlint lint --strictclean on changed files.AXFocusedacross an NSPopover window is not deterministic in CI (the popover window must be key before accessibility queries are valid).Manual verification