diff --git a/core/flyout_vertical.ts b/core/flyout_vertical.ts index a4bfec158..4ab2523be 100644 --- a/core/flyout_vertical.ts +++ b/core/flyout_vertical.ts @@ -233,29 +233,32 @@ export class VerticalFlyout extends Flyout { for (let i = 0, item; (item = contents[i]); i++) { if (item.type === 'block') { const block = item.block; - const allBlocks = block!.getDescendants(false); + if (!block) { + continue; + } + const allBlocks = block.getDescendants(false); for (let j = 0, child; (child = allBlocks[j]); j++) { // Mark blocks as being inside a flyout. This is used to detect and // prevent the closure of the flyout if the user right-clicks on such // a block. child.isInFlyout = true; } - const root = block!.getSvgRoot(); - const blockHW = block!.getHeightWidth(); - const moveX = block!.outputConnection + const root = block.getSvgRoot(); + const blockHW = block.getHeightWidth(); + const moveX = block.outputConnection ? cursorX - this.tabWidth_ : cursorX; - block!.moveBy(moveX, cursorY); + block.moveBy(moveX, cursorY); const rect = this.createRect_( - block!, + block, this.RTL ? moveX - blockHW.width : moveX, cursorY, blockHW, i, ); - this.addBlockListeners_(root, block!, rect); + this.addBlockListeners_(root, block, rect); cursorY += blockHW.height + gaps[i]; } else if (item.type === 'button') {