fix(toolbar): show real keyboard shortcuts in button tooltips (#1694)#1711
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 inMainWindowToolbar+Buttons.swiftare hardcoded shortcut strings.ConnectionToolbarButtonhardcoded⌘⌥C, which had drifted from the canonical binding inKeyboardShortcutModels.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:
KeyboardSettings.shortcutHint(_:for:), which resolves the live shortcut (honoring user overrides) and renders it through the canonicalBoundKey.displayString.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
ShortcutHintTestsinKeyboardShortcutTests: the default Switch Connection hint isSwitch 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
docs/features/keyboard-shortcuts.mdxalready listsCmd+Control+C.swiftlint --strictclean on the changed files.