Skip to content

DEV: Add ability to hide shortcut in title #32860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2025

Conversation

keegangeorge
Copy link
Member

🔍 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:

Cheese (Ctrl + Alt + S)

→ After

Title shows:

Cheese

@keegangeorge keegangeorge merged commit 1a5377c into main May 22, 2025
17 checks passed
@keegangeorge keegangeorge deleted the dev-ability-to-hide-shortcut branch May 22, 2025 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants