diff --git a/src/components/ui/toolbox.ts b/src/components/ui/toolbox.ts index 51648287b..f970c34a0 100644 --- a/src/components/ui/toolbox.ts +++ b/src/components/ui/toolbox.ts @@ -308,7 +308,7 @@ export default class Toolbox extends EventsDispatcher { /** * Maps tool data to popover item structure */ - const toPopoverItem = (toolboxItem: ToolboxConfigEntry, tool: BlockToolAdapter, index?: number): PopoverItemParams => { + const toPopoverItem = (toolboxItem: ToolboxConfigEntry, tool: BlockToolAdapter, displaySecondaryLabel?: boolean): PopoverItemParams => { return { icon: toolboxItem.icon, title: I18n.t(I18nInternalNS.toolNames, toolboxItem.title || _.capitalize(tool.name)), @@ -316,7 +316,7 @@ export default class Toolbox extends EventsDispatcher { onActivate: (): void => { this.toolButtonActivated(tool.name, toolboxItem.data); }, - secondaryLabel: (tool.shortcut && index === 0) ? _.beautifyShortcut(tool.shortcut) : '', + secondaryLabel: (tool.shortcut && displaySecondaryLabel) ? _.beautifyShortcut(tool.shortcut) : '', }; }; @@ -324,7 +324,7 @@ export default class Toolbox extends EventsDispatcher { .reduce((result, tool) => { if (Array.isArray(tool.toolbox)) { tool.toolbox.forEach((item, index) => { - result.push(toPopoverItem(item, tool, index)); + result.push(toPopoverItem(item, tool, index === 0)); }); } else if (tool.toolbox !== undefined) { result.push(toPopoverItem(tool.toolbox, tool)); diff --git a/test/cypress/tests/ui/toolbox.cy.ts b/test/cypress/tests/ui/toolbox.cy.ts index de5015bce..ea7f9a0d0 100644 --- a/test/cypress/tests/ui/toolbox.cy.ts +++ b/test/cypress/tests/ui/toolbox.cy.ts @@ -152,10 +152,10 @@ describe('Toolbox', function () { .type('Some text') .type('/'); // call a shortcut for toolbox - /** * Secondary title (shortcut) should exist for first toolbox item of the tool */ + /* eslint-disable-next-line cypress/require-data-selectors */ cy.get('.ce-popover') .find('.ce-popover-item[data-item-name="severalToolboxItemsTool"]') .first() @@ -165,6 +165,7 @@ describe('Toolbox', function () { /** * Secondary title (shortcut) should not exist for second toolbox item of the same tool */ + /* eslint-disable-next-line cypress/require-data-selectors */ cy.get('.ce-popover') .find('.ce-popover-item[data-item-name="severalToolboxItemsTool"]') .eq(1)