Skip to content
Merged
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
6 changes: 4 additions & 2 deletions packages/blockly/blocks/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -757,13 +757,15 @@ const JOIN_MUTATOR_MIXIN = {
'text_create_join_container',
) as BlockSvg;
containerBlock.initSvg();
let connection = containerBlock.getInput('STACK')!.connection!;
let connection = containerBlock.getInput('STACK')?.connection;
for (let i = 0; i < this.itemCount_; i++) {
const itemBlock = workspace.newBlock(
'text_create_join_item',
) as JoinItemBlock;
itemBlock.initSvg();
connection.connect(itemBlock.previousConnection);
if (itemBlock.previousConnection) {
connection?.connect(itemBlock.previousConnection);
}
connection = itemBlock.nextConnection;
}
return containerBlock;
Expand Down
9 changes: 3 additions & 6 deletions packages/blockly/core/block_svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,9 @@ export class BlockSvg
private visuallyDisabled = false;

override workspace: WorkspaceSvg;
// TODO(b/109816955): remove '!', see go/strict-prop-init-fix.
override outputConnection!: RenderedConnection;
// TODO(b/109816955): remove '!', see go/strict-prop-init-fix.
override nextConnection!: RenderedConnection;
// TODO(b/109816955): remove '!', see go/strict-prop-init-fix.
override previousConnection!: RenderedConnection;
override outputConnection: RenderedConnection | null = null;
override nextConnection: RenderedConnection | null = null;
override previousConnection: RenderedConnection | null = null;

private translation = '';

Expand Down
16 changes: 11 additions & 5 deletions packages/blockly/core/dragging/block_drag_strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ export class BlockDragStrategy implements IDragStrategy {
};
}

this.startChildConn = nextTargetConn;
this.startChildConn = nextTargetConn ?? null;
}
}
}
Expand Down Expand Up @@ -627,7 +627,7 @@ export class BlockDragStrategy implements IDragStrategy {
draggingBlock.outputConnection,
draggingBlock.previousConnection,
draggingBlock.nextConnection,
].filter(Boolean); // Removes falsy (null) values.
].filter((c) => !!c); // Removes falsy (null) values.
const inputConnections: RenderedConnection[] = [];

for (const conn of available) {
Expand Down Expand Up @@ -727,14 +727,20 @@ export class BlockDragStrategy implements IDragStrategy {
this.connectionPreviewer?.hidePreview();
this.connectionCandidate = null;

this.startChildConn?.connect(this.block.nextConnection);
if (this.block.nextConnection) {
this.startChildConn?.connect(this.block.nextConnection);
}
if (this.startParentConn) {
switch (this.startParentConn.type) {
case ConnectionType.INPUT_VALUE:
this.startParentConn.connect(this.block.outputConnection);
if (this.block.outputConnection) {
this.startParentConn.connect(this.block.outputConnection);
}
break;
case ConnectionType.NEXT_STATEMENT:
this.startParentConn.connect(this.block.previousConnection);
if (this.block.previousConnection) {
this.startParentConn.connect(this.block.previousConnection);
}
}
} else {
this.block.moveTo(this.startLoc!, ['drag']);
Expand Down
2 changes: 1 addition & 1 deletion packages/blockly/core/renderers/common/drawer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ export class Drawer {
const x =
this.info_.startX + this.info_.outputConnection.connectionOffsetX;
const connX = this.info_.RTL ? -x : x;
this.block_.outputConnection.setOffsetInBlock(
this.block_.outputConnection?.setOffsetInBlock(
connX,
this.info_.outputConnection.connectionOffsetY,
);
Expand Down
Loading