fix: Fix bug that caused blocks inserted via Enter to not attach (#9699)

This commit is contained in:
Aaron Dodson
2026-04-15 08:29:43 -07:00
committed by GitHub
parent 91d02eee02
commit 0c4ec192ba
4 changed files with 16 additions and 4 deletions
+2 -2
View File
@@ -1918,9 +1918,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) {
@@ -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;
}
/**
+1 -1
View File
@@ -861,7 +861,7 @@ export function registerPerformAction() {
const focusedNode = getFocusManager().getFocusedNode();
if (focusedNode && 'performAction' in focusedNode) {
e.preventDefault();
focusedNode.performAction?.();
focusedNode.performAction?.(e);
return true;
}
return false;
@@ -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()
@@ -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();
});