From 1a63a39cf64baeb488536432a1abfdf23352ba52 Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Sat, 30 May 2026 13:31:01 +0700 Subject: [PATCH] fix(hig): dismiss search sheets and popovers with Escape (#1490) --- CHANGELOG.md | 1 + .../Views/DatabaseSwitcher/DatabaseSwitcherSheet.swift | 1 + TablePro/Views/Sidebar/NativeSearchField.swift | 8 ++++---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fb6db50b..d0d7e0ee9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Escape now dismisses search-based sheets and popovers (database switcher, quick switcher, column and connection pickers). Pressing Escape clears the search text first; a second Escape closes the sheet. (#1490) - Running `EXPLAIN` or `EXPLAIN ANALYZE` typed in the editor now opens the plan viewer instead of squashing the plan into one truncated grid cell. (#1480) - Filtering the data grid keeps you on the keyboard. Applying or clearing a filter returns focus to the grid so you can keep moving through cells, Return applies the filter, and Escape closes the filter panel and returns to the grid. (#1490) - Opening a table (Return or double-click in the sidebar) moves keyboard focus into the data grid so you can navigate cells with the arrow keys. Arrowing the sidebar still previews tables without taking focus. (#1490) diff --git a/TablePro/Views/DatabaseSwitcher/DatabaseSwitcherSheet.swift b/TablePro/Views/DatabaseSwitcher/DatabaseSwitcherSheet.swift index 9743ca90e..c08e73108 100644 --- a/TablePro/Views/DatabaseSwitcher/DatabaseSwitcherSheet.swift +++ b/TablePro/Views/DatabaseSwitcher/DatabaseSwitcherSheet.swift @@ -70,6 +70,7 @@ struct DatabaseSwitcherSheet: View { } } .frame(width: 480, height: 460) + .onExitCommand { dismiss() } .task { await viewModel.fetchDatabases() } } diff --git a/TablePro/Views/Sidebar/NativeSearchField.swift b/TablePro/Views/Sidebar/NativeSearchField.swift index 3062710c4..adb3e8211 100644 --- a/TablePro/Views/Sidebar/NativeSearchField.swift +++ b/TablePro/Views/Sidebar/NativeSearchField.swift @@ -94,11 +94,11 @@ struct NativeSearchField: NSViewRepresentable { func control(_ control: NSControl, textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool { if commandSelector == #selector(NSResponder.cancelOperation(_:)) { - guard let field = control as? NSSearchField else { return false } - if !field.stringValue.isEmpty { - field.stringValue = "" - text.wrappedValue = "" + guard let field = control as? NSSearchField, !field.stringValue.isEmpty else { + return false } + field.stringValue = "" + text.wrappedValue = "" return true } if commandSelector == #selector(NSResponder.moveUp(_:)), let onMoveUp {