diff --git a/packages/blockly/core/shortcut_items.ts b/packages/blockly/core/shortcut_items.ts index caa8ea84c9d..3e3e3c9e4ed 100644 --- a/packages/blockly/core/shortcut_items.ts +++ b/packages/blockly/core/shortcut_items.ts @@ -217,7 +217,9 @@ export function registerCut() { if (focused instanceof BlockSvg) { focused.checkAndDelete(); } else if (isIDeletable(focused)) { + eventUtils.setGroup(true); focused.dispose(); + eventUtils.setGroup(false); } return !!copyData; }, diff --git a/packages/blockly/tests/mocha/shortcut_items_test.js b/packages/blockly/tests/mocha/shortcut_items_test.js index 99c7bd4d0f9..0a42c41ba7f 100644 --- a/packages/blockly/tests/mocha/shortcut_items_test.js +++ b/packages/blockly/tests/mocha/shortcut_items_test.js @@ -295,6 +295,11 @@ suite('Keyboard Shortcut Items', function () { this.disposeSpy = sinon.spy(this.comment, 'dispose'); this.injectionDiv.dispatchEvent(keyEvent); + + const deleteEvents = this.workspace + .getUndoStack() + .filter((e) => e.type === 'comment_delete'); + assert(deleteEvents[0].group !== ''); // Group string is not empty sinon.assert.calledOnce(this.copySpy); sinon.assert.calledOnce(this.disposeSpy); });