mirror of
https://github.com/google/blockly.git
synced 2026-04-26 23:20:22 +02:00
fix: Fix bug that caused blocks inserted via Enter to not attach (#9699)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user