From 19e91159081ae98820a36cbcf8a4e23950877702 Mon Sep 17 00:00:00 2001 From: Rashmi Patel <35393664+rashmi29@users.noreply.github.com> Date: Mon, 25 Sep 2023 11:25:46 -0700 Subject: [PATCH] fix: non-nullable check for block variable and removed ! in layout_ (#7536) * Fix: 7523 - non-nullable check for block variable and removed ! * Fix: non nullable check for block variable * fix: fixed styling issue * fix: updated block variable nullable condition * Updated nullable condition for block variable --- core/flyout_vertical.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) 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') {