Skip to content

fix(toolbar): show real keyboard shortcuts in button tooltips (#1694)#1711

Merged
datlechin merged 1 commit into
mainfrom
fix-1694-toolbar-shortcut-tooltip
Jun 17, 2026
Merged

fix(toolbar): show real keyboard shortcuts in button tooltips (#1694)#1711
datlechin merged 1 commit into
mainfrom
fix-1694-toolbar-shortcut-tooltip

Conversation

@datlechin

Copy link
Copy Markdown
Member

Fixes #1694.

Problem

The "Switch Connection" toolbar button's tooltip read Switch Connection (⌘⌥C), but the real default shortcut is ⌃⌘C (Cmd+Control+C).

Root cause

The toolbar .help() tooltips in MainWindowToolbar+Buttons.swift are hardcoded shortcut strings. ConnectionToolbarButton hardcoded ⌘⌥C, which had drifted from the canonical binding in KeyboardShortcutModels.swift (.switchConnection = .character("c", command: true, control: true)). Every toolbar tooltip shares this flaw: it can drift, and it ignores user rebindings (these shortcuts are customizable). Several also used the wrong modifier order (⌘⇧ instead of the macOS-standard ⇧⌘).

Fix

Root-cause refactor rather than swapping one symbol:

  • Add KeyboardSettings.shortcutHint(_:for:), which resolves the live shortcut (honoring user overrides) and renders it through the canonical BoundKey.displayString.
  • Rewire all toolbar tooltips to derive from it, so they show the real shortcut and follow rebindings. Dashboard (no shortcut) stays a plain label.
  • Collapse the three duplicate copies of this helper (MainStatusBarView, QueryEditorView, PaginationControlsView) to delegate to the shared method, removing the duplication that let the toolbar drift.

The reported tooltip now reads Switch Connection (⌃⌘C), and Preview/Results/Export/Import pick up the correct modifier order too.

Tests

New ShortcutHintTests in KeyboardShortcutTests: the default Switch Connection hint is Switch Connection (⌃⌘C), a user override updates the hint, and a cleared or unset shortcut shows the label only. All pass; existing keyboard suites unchanged.

Notes

  • No docs change: the shortcut value is unchanged (only the displayed tooltip), and docs/features/keyboard-shortcuts.mdx already lists Cmd+Control+C.
  • swiftlint --strict clean on the changed files.

@datlechin datlechin merged commit e667934 into main Jun 17, 2026
2 of 3 checks passed
@datlechin datlechin deleted the fix-1694-toolbar-shortcut-tooltip branch June 17, 2026 16:21
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.

Wrong keyboard shortcut shown in “Switch Connection” tooltip

1 participant