Don't split dropdown text if there is an image.

This commit is contained in:
Neil Fraser
2016-11-11 04:27:54 -08:00
parent 01ab0b4ab6
commit 32713726dc
2 changed files with 7 additions and 8 deletions

View File

@@ -246,9 +246,10 @@ Blockly.FieldDropdown.prototype.trimOptions_ = function() {
var strings = [];
for (var i = 0; i < options.length; i++) {
var text = options[i][0];
if (typeof text == 'string') {
strings.push(text);
if (typeof text != 'string') {
return; // No text splitting if there is an image in the list.
}
strings.push(text);
}
var shortest = Blockly.shortestStringLength(strings);
var prefixLength = Blockly.commonWordPrefix(strings, shortest);
@@ -270,11 +271,9 @@ Blockly.FieldDropdown.prototype.trimOptions_ = function() {
var newOptions = [];
for (var i = 0; i < options.length; i++) {
var text = options[i][0];
if (typeof text == 'string') {
var value = options[i][1];
text = text.substring(prefixLength, text.length - suffixLength);
newOptions[i] = [text, value];
}
var value = options[i][1];
text = text.substring(prefixLength, text.length - suffixLength);
newOptions[i] = [text, value];
}
this.menuGenerator_ = newOptions;
};

View File

@@ -92,7 +92,7 @@ Blockly.hasClass_ = function(element, className) {
/**
* Bind an event to a function call. When calling the function, verifies that
* it belongs to the touch stream that is currently being processsed, and splits
* it belongs to the touch stream that is currently being processed, and splits
* multitouch events into multiple events as needed.
* @param {!Node} node Node upon which to listen.
* @param {string} name Event name to listen to (e.g. 'mousedown').