Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core/field_dropdown : always return something. #14

Closed
wants to merge 10 commits into from
13 changes: 9 additions & 4 deletions core/field_dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ Blockly.FieldDropdown.prototype.init = function() {
*/
Blockly.FieldDropdown.prototype.showEditor_ = function() {
var options = this.getOptions();
if (options.length == 0) return;
if (options.length == 0 || options == ['']) return;
LilyMakesThings marked this conversation as resolved.
Show resolved Hide resolved

this.dropDownOpen_ = true;
// If there is an existing drop-down someone else owns, hide it immediately and clear it.
Expand Down Expand Up @@ -331,10 +331,15 @@ Blockly.FieldDropdown.prototype.isOptionListDynamic = function() {
* (human-readable text or image, language-neutral name).
*/
Blockly.FieldDropdown.prototype.getOptions = function() {
var options = [];

if (goog.isFunction(this.menuGenerator_)) {
return this.menuGenerator_.call(this);
}
return /** @type {!Array.<!Array.<string>>} */ (this.menuGenerator_);
options = this.menuGenerator_.call(this);
} else options = (this.menuGenerator_);

/** @type {!Array.<!Array.<string>>} */
if (options.length > 0) return options;
return [''];
};

/**
Expand Down