Fixes bug with using dynamic variable in toolbox

This commit is contained in:
alschmiedt
2019-07-09 11:02:02 -07:00
parent a5892f8e27
commit f30d79fbc8
3 changed files with 13 additions and 5 deletions

View File

@@ -348,12 +348,20 @@ Blockly.VariableMap.prototype.getVariablesOfType = function(type) {
};
/**
* Return all variable types. This list always contains the empty string.
* Return all variable and potential variable types. This list always contains
* the empty string.
* @param {?Blockly.Workspace} ws The workspace used to look for potential
* variables. This can be different than the workspace stored on this object
* if the passed in ws is a flyout workspace.
* @return {!Array.<string>} List of variable types.
* @package
*/
Blockly.VariableMap.prototype.getVariableTypes = function() {
var types = Object.keys(this.variableMap_);
Blockly.VariableMap.prototype.getVariableTypes = function(ws) {
var potentialTypes = [];
if (ws && ws.getPotentialVariableMap()) {
potentialTypes = Object.keys(ws.getPotentialVariableMap().variableMap_);
}
var types = Object.keys(this.variableMap_).concat(potentialTypes);
var hasEmpty = false;
for (var i = 0; i < types.length; i++) {
if (types[i] == '') {