diff --git a/accessible/field-segment.component.js b/accessible/field-segment.component.js index cdf48993d..8dda20d71 100644 --- a/accessible/field-segment.component.js +++ b/accessible/field-segment.component.js @@ -58,11 +58,10 @@ blocklyApp.FieldSegmentComponent = ng.core.Component({ {{getPrefixText()}} @@ -92,6 +91,7 @@ blocklyApp.FieldSegmentComponent = ng.core.Component({ ngDoCheck: function() { if (this.isDropdown() && this.shouldBreakCache()) { this.optionValue = this.mainField.getValue(); + this.fieldValue = this.mainField.getValue(); this.rawOptions = this.mainField.getOptions(); this.dropdownOptions = this.rawOptions.map(function(valueAndText) { return { @@ -99,6 +99,13 @@ blocklyApp.FieldSegmentComponent = ng.core.Component({ value: valueAndText[1] }; }); + + // Set the currently selected value to the variable on the field. + for (var i = 0; i < this.dropdownOptions.length; i++) { + if (this.dropdownOptions[i].text === this.fieldValue) { + this.selectedOption = this.dropdownOptions[i].value; + } + } } }, // Returns whether the mutable, cached information needs to be refreshed. @@ -110,11 +117,15 @@ blocklyApp.FieldSegmentComponent = ng.core.Component({ for (var i = 0; i < this.rawOptions.length; i++) { // Compare the value of the cached options with the values in the field. - if (newOptions[i][1] != this.rawOptions[i][1]) { + if (newOptions[i][0] != this.rawOptions[i][0]) { return true; } } + if (this.fieldValue != this.mainField.getValue()) { + return true; + } + return false; }, // Gets the prefix text, to be printed before a field. diff --git a/accessible/variable-add-modal.component.js b/accessible/variable-add-modal.component.js index e113b49fb..288aa896c 100644 --- a/accessible/variable-add-modal.component.js +++ b/accessible/variable-add-modal.component.js @@ -52,10 +52,10 @@ blocklyApp.VariableAddModalComponent = ng.core.Component({ aria-labelledby="inputLabel" />