fix(hig): dismiss search sheets and popovers with Escape (#1490)#1502
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.
Part of #1490 (keyboard, focus, accessibility).
Problem
NativeSearchField(the sharedNSSearchFieldwrapper) always returnedtrueforcancelOperation, even when the field was empty, so Escape was swallowed and never reached the enclosing sheet or popover. Pressing Escape in the database switcher or quick switcher did nothing; you had to Tab to Cancel or click. The same swallow blocked Escape from closing the search popovers (column visibility, connection switcher, type picker).DatabaseSwitcherSheetalso had no container Escape handler.Fix (standard NSSearchField behavior)
NativeSearchField.cancelOperation: when the field has text, clear it and consume the key (returntrue); when the field is empty, returnfalseso Escape propagates up the responder chain to the enclosing sheet or popover. This is the documented search-field convention: first Escape clears, second Escape dismisses.DatabaseSwitcherSheet: add.onExitCommand { dismiss() }. (QuickSwitcherSheetalready had one, so it starts working once the search field stops swallowing Escape.)No custom focus machinery; this restores the native responder-chain behavior the search field was short-circuiting.
Scope note
NativeSearchFieldis shared across ~17 call sites. This change also lets Escape-when-empty close the four search popovers (column visibility, database/connection switcher, type picker) and propagate normally in settings and inline panels. That is an improvement and matches native behavior; a propagated Escape with no handler is a no-op, so nothing should regress.Verify
Out of scope (separate #1490 follow-ups)
Initial-focus gaps (
MCPTokenRevealSheet,LicenseActivationSheet),SQLReviewSheetEscape-from-editor (needs verifying whether the editor releases Escape), accessibility hints on dialog toggles, and theAlertHelper.runModal()fallback.Focus/responder behavior is not unit-testable here (consistent with the codebase); verification is manual.