Skip to content

fix(datagrid): Esc in the filter suggestions or a search field no longer exits fullscreen (#1403)#1406

Merged
datlechin merged 1 commit into
mainfrom
fix/1403-esc-fullscreen
May 24, 2026
Merged

fix(datagrid): Esc in the filter suggestions or a search field no longer exits fullscreen (#1403)#1406
datlechin merged 1 commit into
mainfrom
fix/1403-esc-fullscreen

Conversation

@datlechin
Copy link
Copy Markdown
Member

@datlechin datlechin commented May 24, 2026

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's NSHostingView, which exits fullscreen on an unhandled exit command. The trace:

NSTextView.keyDown -> interpretKeyEvents -> doCommandBySelector(cancelOperation:)
  -> SwiftUI NSHostingView.doCommand(by:) -> _NSFullScreenSpace exit transition

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 NSHostingView reacting to an unconsumed exit command.

Two text fields let Esc through to the hosting view:

  • The Raw SQL filter's suggestion monitor handled Esc but returned the event instead of consuming it.
  • NativeSearchField returned false from its delegate when the field was empty, so Esc propagated.

Fix

Consume cancelOperation: at the text field's delegate (control(_:textView:doCommandBy:) returning true), so it never reaches NSHostingView. This is the same mechanism NativeSearchField already 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, testable suggestionKeyOutcome(for:submitsOnAccept:).
  • NativeSearchField: an empty-field Esc is now consumed instead of propagating.

Tests

FilterValueTextFieldTests asserts escape -> .dismiss (a consuming outcome) plus the arrow/return/tab/pass-through mappings.

Verify (in fullscreen)

  • Raw SQL filter: type a value to open the popup, Esc closes the popup and stays fullscreen. Esc again with no popup stays fullscreen.
  • Search field: Esc with text clears it and stays fullscreen; Esc on an empty field stays fullscreen.
  • Regression: green button and Ctrl+Cmd+F still exit 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.

@datlechin datlechin force-pushed the fix/1403-esc-fullscreen branch from f7b7cdc to d6e8c48 Compare May 24, 2026 06:56
@datlechin datlechin changed the title fix(tabs): keep Esc from exiting fullscreen when it dismisses the filter popup or clears search (#1403) fix(datagrid): Esc in the filter suggestions or a search field no longer exits fullscreen (#1403) May 24, 2026
@datlechin datlechin merged commit dadb8c0 into main May 24, 2026
2 checks passed
@datlechin datlechin deleted the fix/1403-esc-fullscreen branch May 24, 2026 06:57
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.

Pressing Esc in Raw SQL filter autocomplete also exits fullscreen mode

1 participant