Skip to content

feat(sidebar): keyboard control of the sidebar filter and tabs (#1490)#1504

Merged
datlechin merged 1 commit into
mainfrom
fix/sidebar-keyboard-nav
May 30, 2026
Merged

feat(sidebar): keyboard control of the sidebar filter and tabs (#1490)#1504
datlechin merged 1 commit into
mainfrom
fix/sidebar-keyboard-nav

Conversation

@datlechin
Copy link
Copy Markdown
Member

Part of #1490 (keyboard, focus, accessibility). Sidebar surface.

What this adds (keyboard-only)

  • Focus the sidebar filter with a shortcut (default Cmd+Option+F). Expands the sidebar if collapsed, then focuses the search field.
  • From the filter field, move into the list: Tab (via nextKeyView) or the Down arrow (handled in the search-field delegate) hands focus to the list. Arrow keys then navigate rows and Return opens, which already worked natively.
  • Switch sidebars by keyboard: Show Tables (Control+1) and Show Favorites (Control+2), routed through the same setSidebarTab the toolbar buttons use.
  • All three are real ShortcutActions, so they appear under the View menu and are rebindable in Settings, Keyboard.

Accessibility

  • The sidebar search field now has a VoiceOver label ("Filter" / "Filter favorites", kept in sync with the active tab) instead of only an identifier string.
  • Database and schema disclosure headers in the tree get .accessibilityLabel ("Database: X" / "Schema: Y") and the .isHeader trait.

Native approach

No custom focus engine: the focus shortcut uses window.makeFirstResponder(searchField), the Tab handoff uses the AppKit key view loop (searchField.nextKeyView = hostingView), and the Down-arrow handoff uses the standard control(_:textView:doCommandBy:) search-field delegate. Tab order and arrow navigation inside the list are the native NSOutlineView behavior that List(.sidebar) already provides.

Files

  • KeyboardShortcutModels.swift: 3 actions (focusSidebarSearch, showSidebarTables, showSidebarFavorites) with display names and default keys.
  • SidebarContainerViewController.swift: focusSearchField(), nextKeyView, Down-arrow handoff, a11y label.
  • MainSplitViewController.swift: focusSidebarSearch().
  • MainContentCommandActions.swift: focusSidebarSearch(), showSidebarTab(_:).
  • TableProApp.swift: View-menu items.
  • DatabaseTreeView.swift: header a11y labels.
  • CHANGELOG + keyboard-shortcuts doc.

Verify (build needed)

  • Cmd+Option+F focuses the sidebar filter from anywhere in the window (expands the sidebar if collapsed).
  • With the filter focused, Tab or Down arrow moves into the list; arrows navigate; Return opens.
  • Control+1 / Control+2 switch the Tables / Favorites sidebars.
  • VoiceOver announces the filter field and the database/schema headers with real labels.

The one thing to confirm on a real build is the search -> list focus handoff (Tab and Down arrow), since it crosses the AppKit search field into the SwiftUI list inside the hosting view. If it does not land, the fix is local to SidebarContainerViewController.

Focus/responder behavior is not unit-testable here (consistent with the codebase); verification is manual.

@datlechin datlechin merged commit 4484bb0 into main May 30, 2026
4 checks passed
@datlechin datlechin deleted the fix/sidebar-keyboard-nav branch May 30, 2026 06:47
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 24d31d1931

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +499 to +502
if sidebarSplitItem?.isCollapsed == true {
sidebarSplitItem?.animator().isCollapsed = false
}
sidebarContainer.focusSearchField()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Delay focus until the sidebar finishes expanding

When the sidebar is collapsed, this starts an animated expand and immediately calls focusSearchField() while the search field is still inside the collapsed split item. In that state AppKit can leave first responder unchanged because the target view is not yet visible, so the advertised Cmd+Option+F path only opens the sidebar instead of focusing the filter. Expand synchronously or dispatch the makeFirstResponder call after the split item has been uncollapsed.

Useful? React with 👍 / 👎.

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