Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/blockly/core/block_svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1911,9 +1911,9 @@ export class BlockSvg
* main workspace. If this block has a single full-block field, that field
* will be focused. Otherwise, this is a no-op.
*/
performAction() {
performAction(e?: KeyboardEvent) {
if (this.workspace.isFlyout) {
KeyboardMover.mover.startMove(this);
KeyboardMover.mover.startMove(this, e);
return;
} else if (this.isSimpleReporter()) {
for (const input of this.inputList) {
Expand Down
4 changes: 3 additions & 1 deletion packages/blockly/core/interfaces/i_focusable_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ export interface IFocusableNode {
* Optional method invoked when this node has focus and the user acts on it by
* pressing Enter or Space. Behavior should generally be similar to the node
* being clicked on.
*
* @param e The event that triggered this action, if any.
*/
performAction?(): void;
performAction?(e?: Event): void;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/blockly/core/shortcut_items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ export function registerPerformAction() {
const focusedNode = getFocusManager().getFocusedNode();
if (focusedNode && 'performAction' in focusedNode) {
e.preventDefault();
focusedNode.performAction?.();
focusedNode.performAction?.(e);
return true;
}
return false;
Expand Down
10 changes: 10 additions & 0 deletions packages/blockly/tests/mocha/shortcut_items_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,10 @@ suite('Keyboard Shortcut Items', function () {
});

test('Inserts blocks from the flyout in move mode', function () {
const first = this.workspace.newBlock('stack_block');
first.initSvg();
first.render();

this.workspace.getToolbox().selectItemByPosition(0);
const block = this.workspace
.getNavigator()
Expand All @@ -1053,6 +1057,12 @@ suite('Keyboard Shortcut Items', function () {
assert.isTrue(movingBlock.isDragging());
assert.isFalse(movingBlock.workspace.isFlyout);

const hasInsertionMarker = this.workspace
.getTopBlocks()
.flatMap((b) => b.getChildren())
.some((b) => b.isInsertionMarker());
assert.isTrue(hasInsertionMarker);

Blockly.KeyboardMover.mover.abortMove();
});

Expand Down
Loading