DEV: Add ability to hide shortcut in title #32860
Merged
+35
−1
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.
🔍 Overview
This update add an optional attribute to the
toolbar.addButton()
API so that we can conditionally hide the shortcut showing up in the title.Although for most cases, showing the shortcut in the title is fine. For complex uses of
toolbar.addButton
where it triggers a menu, it isn't ideal. For example, in Discourse AI, the toolbar API is used to show a menu for the AI composer helper. The shortcut in the API is used to trigger the proofreading item, but not necessarily for all other items. As such, we want the shortcut hidden in the title.🛠️ Usage
withPluginApi((api) => { api.onToolbarCreate((toolbar) => { toolbar.addButton({ id: "smile", group: "extras", name: "smile", icon: "far-face-smile", title: "cheese", shortcut: "ALT+S", + hideShortcutInTitle: true, }); }); });
← Before
Title shows:
→ After
Title shows: