From e84a740d3d7bf1d20a31f02e7eba2f9557873d35 Mon Sep 17 00:00:00 2001 From: Bluefox Date: Fri, 22 Feb 2019 19:02:14 +0100 Subject: [PATCH] Fix error by init of dropdown in case the value is "" (#2308) I have following dropdown options ``` [ ["no matter", ""] ["Update", "true"] ["Command", "false"] ] ``` In case my value is "" the text is not filled with "no matter" by the initial draw and the empty selector is shown. I expect the text "no matter" This PR fixes that --- core/field_dropdown.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/field_dropdown.js b/core/field_dropdown.js index 1de845765..3751508f1 100644 --- a/core/field_dropdown.js +++ b/core/field_dropdown.js @@ -392,8 +392,8 @@ Blockly.FieldDropdown.prototype.getValue = function() { * @param {string} newValue New value to set. */ Blockly.FieldDropdown.prototype.setValue = function(newValue) { - if (newValue === null || newValue === this.value_) { - return; // No change if null. + if (newValue === null || (newValue === this.value_ && this.text_)) { + return; // No change if null and text_ was initialized. } if (this.sourceBlock_ && Blockly.Events.isEnabled()) { Blockly.Events.fire(new Blockly.Events.BlockChange(