Skip to content

Commit 5869ad6

Browse files
committed
Makes height dependent on what is in flydown
1 parent 7f15fdb commit 5869ad6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/fields/field_flydown.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class CustomFlyout extends Blockly.VerticalFlyout {
4545
return;
4646
}
4747

48+
this.height_ = this.getHeight();
49+
4850
const edgeWidth = this.width_ - this.CORNER_RADIUS;
4951
const edgeHeight = this.height_ - 2 * this.CORNER_RADIUS;
5052

@@ -55,6 +57,21 @@ class CustomFlyout extends Blockly.VerticalFlyout {
5557

5658
this.positionAt_(this.width_, this.height_, x, y);
5759
}
60+
protected getHeight(): number {
61+
let flydownWorkspace = this.getWorkspace();
62+
if (!flydownWorkspace) {
63+
return 0;
64+
}
65+
const blocks = flydownWorkspace.getAllBlocks();
66+
let height = 0;
67+
blocks.forEach((block : Blockly.BlockSvg) => {
68+
const blockHeight = block.getHeightWidth().height;
69+
height += blockHeight + this.GAP_Y; // Add some padding between blocks
70+
});
71+
72+
return height;
73+
}
74+
5875

5976
/**
6077
* Create and set the path for the visible boundaries of the flyout.

0 commit comments

Comments
 (0)