From dbcef018d4e1a2be3408a0bd6ee189f2d2073161 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Wed, 14 Feb 2024 01:51:13 +0000 Subject: [PATCH] Fix shadow dependency --- core/field_angle.js | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/core/field_angle.js b/core/field_angle.js index f178a2a748..9859119005 100644 --- a/core/field_angle.js +++ b/core/field_angle.js @@ -246,10 +246,28 @@ Blockly.FieldAngle.prototype.showEditor_ = function() { Blockly.mainWorkspace.options.pathToMedia + Blockly.FieldAngle.ARROW_SVG_PATH ); - Blockly.DropDownDiv.setColour(this.sourceBlock_.parentBlock_.getColour(), - this.sourceBlock_.getColourTertiary()); - Blockly.DropDownDiv.setCategory(this.sourceBlock_.parentBlock_.getCategory()); - Blockly.DropDownDiv.showPositionedByBlock(this, this.sourceBlock_); + if (this.sourceBlock_.isShadow()) { + Blockly.DropDownDiv.setColour(this.sourceBlock_.parentBlock_.getColour(), + this.sourceBlock_.getColourTertiary()); + Blockly.DropDownDiv.setCategory(this.sourceBlock_.parentBlock_.getCategory()); + Blockly.DropDownDiv.showPositionedByBlock(this, this.sourceBlock_); + } else { + // Calculate positioning based on the field position. + var scale = this.sourceBlock_.workspace.scale; + var bBox = {width: this.size_.width, height: this.size_.height}; + bBox.width *= scale; + bBox.height *= scale; + var position = this.fieldGroup_.getBoundingClientRect(); + var primaryX = position.left + bBox.width / 2; + var primaryY = position.top + bBox.height; + var secondaryX = primaryX; + var secondaryY = position.top; + + Blockly.DropDownDiv.setColour(this.sourceBlock_.getColour(), + this.sourceBlock_.getColourTertiary()); + Blockly.DropDownDiv.setCategory(this.sourceBlock_.getCategory()); + Blockly.DropDownDiv.show(this, this.sourceBlock_); + } this.mouseDownWrapper_ = Blockly.bindEvent_(this.handle_, 'mousedown', this, this.onMouseDown);