fix(datagrid): Esc in the filter suggestions or a search field no longer exits fullscreen (#1403)#1406
Merged
Merged
Conversation
…ger exits fullscreen (#1403)
f7b7cdc to
d6e8c48
Compare
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.
What
In macOS fullscreen, pressing Esc to dismiss the Raw SQL filter's autocomplete popup also exited fullscreen. Closes #1403. The same leak affected search fields. Esc now stays in fullscreen.
Root cause
The Esc key (
cancelOperation:) reached SwiftUI'sNSHostingView, which exits fullscreen on an unhandled exit command. The trace:So the exit happens at the SwiftUI hosting layer, not at the window. Standard window fullscreen is not exited by Esc natively; that is the green button or Ctrl+Cmd+F. The exit here was
NSHostingViewreacting to an unconsumed exit command.Two text fields let Esc through to the hosting view:
NativeSearchFieldreturnedfalsefrom its delegate when the field was empty, so Esc propagated.Fix
Consume
cancelOperation:at the text field's delegate (control(_:textView:doCommandBy:)returningtrue), so it never reachesNSHostingView. This is the same mechanismNativeSearchFieldalready used for the non-empty case (clearing a search without exiting fullscreen).FilterValueTextField: the delegate now consumes Esc, dismissing the suggestion popup if it is shown. The popup monitor also consumes Esc instead of passing it through. Extracted a pure, testablesuggestionKeyOutcome(for:submitsOnAccept:).NativeSearchField: an empty-field Esc is now consumed instead of propagating.Tests
FilterValueTextFieldTestsassertsescape -> .dismiss(a consuming outcome) plus the arrow/return/tab/pass-through mappings.Verify (in fullscreen)
Scope
This consumes Esc in the filter and search fields (the reported case and the related search-field case). Any other SwiftUI-hosted text field would use the same one-line delegate consume.