Skip to content

fix(datagrid): drive Cmd+F filter toggle from tab context and the View menu#1360

Merged
datlechin merged 2 commits into
mainfrom
fix-datagrid-cmdf-filter-routing
May 20, 2026
Merged

fix(datagrid): drive Cmd+F filter toggle from tab context and the View menu#1360
datlechin merged 2 commits into
mainfrom
fix-datagrid-cmdf-filter-routing

Conversation

@datlechin
Copy link
Copy Markdown
Member

Problem

Cmd+F for the data-grid filter (added in #1339, unreleased) had two bugs:

  1. It only toggled the filter when the data grid happened to be the first responder. Nothing focuses the grid when a table tab opens, so pressing Cmd+F usually fell through to the SQL editor's Find path instead of toggling the filter.
  2. Routing it through the Edit > Find item meant the Edit menu flashed even though "Toggle Filters" lives in the View menu, and the View item never showed a Cmd+F hint. After opening the Edit menu once, Cmd+F stopped working entirely in table tabs.

Cause

  • Bug 1: the action gated on NSApp.keyWindow?.firstResponder is KeyHandlingTableView, but the grid is only made first responder on click, not on tab open.
  • Bug 2: two menu items declared the same Cmd+F. SwiftUI dedupes identical shortcuts (dropping the hint from one item), and once AppKit realized the Edit > Find item it bound Cmd+F to it even though it was .disabled in a table tab. .disabled gates firing, not the dedupe or the key binding.

Fix

Whether Cmd+F means "filter" or "find" is decided by tab context, not focus. A single CommandFRoute value drives both menu items:

Route Cmd+F owner Menu that flashes
table tab View > Toggle Filters View
query tab Edit > Find Edit
inspector window Edit > Find Edit

The shortcut is applied to exactly one item per route, so there's never a duplicate to dedupe or mis-bind, and the Cmd+F hint follows the active context. .toggleFilters is restored to a customizable default of Cmd+F.

Test plan

  • Table tab: Cmd+F toggles the filter without clicking the grid first; View menu flashes; "Toggle Filters" shows ⌘F.
  • Open and close the Edit menu, then Cmd+F in a table tab still toggles the filter.
  • Query tab: Cmd+F opens the editor Find panel; Edit menu shows ⌘F next to "Find…".
  • Inspector window: Cmd+F filters the inspector.

Lint passes (swiftlint --strict).

@datlechin datlechin merged commit e429eab into main May 20, 2026
1 check passed
@datlechin datlechin deleted the fix-datagrid-cmdf-filter-routing branch May 20, 2026 14:50
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.

1 participant