-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: non-nullable check for block variable and removed ! in layout_ #7536
Changes from 5 commits
89bc156
4589a17
a9a0d84
dfb6705
0008925
5cc1ff6
ddee1ca
dce666c
a6bcdc7
f95279a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 == undefined || block == null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This check is redundant, block == null checks both null and undefined. We would both checks with strict equality i.e. block === undefined || block === null There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I just add if (block) than it shows "'block' is possibly 'undefined'." error. So, I added condition if (block == null) as suggested by rachna. |
||
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') { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please squash your commits