mirror of
https://github.com/google/blockly.git
synced 2026-01-07 00:50:27 +01:00
fix collapse bug
This commit is contained in:
@@ -807,16 +807,20 @@ Blockly.Block.prototype.setCollapsed = function(collapsed) {
|
||||
*/
|
||||
Blockly.Block.prototype.toString = function(opt_maxLength) {
|
||||
var text = [];
|
||||
for (var i = 0, input; input = this.inputList[i]; i++) {
|
||||
for (var j = 0, field; field = input.fieldRow[j]; j++) {
|
||||
text.push(field.getText());
|
||||
}
|
||||
if (input.connection) {
|
||||
var child = input.connection.targetBlock();
|
||||
if (child) {
|
||||
text.push(child.toString());
|
||||
} else {
|
||||
text.push('?');
|
||||
if(this.collapsed_) {
|
||||
text.push(this.getInput('_TEMP_COLLAPSED_INPUT').fieldRow[0].text_);
|
||||
} else {
|
||||
for (var i = 0, input; input = this.inputList[i]; i++) {
|
||||
for (var j = 0, field; field = input.fieldRow[j]; j++) {
|
||||
text.push(field.getText());
|
||||
}
|
||||
if (input.connection) {
|
||||
var child = input.connection.targetBlock();
|
||||
if (child) {
|
||||
text.push(child.toString());
|
||||
} else {
|
||||
text.push('?');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,7 +293,6 @@ Blockly.BlockSvg.prototype.setCollapsed = function(collapsed) {
|
||||
if (this.collapsed_ == collapsed) {
|
||||
return;
|
||||
}
|
||||
Blockly.BlockSvg.superClass_.setCollapsed.call(this, collapsed);
|
||||
var renderList = [];
|
||||
// Show/hide the inputs.
|
||||
for (var x = 0, input; input = this.inputList[x]; x++) {
|
||||
@@ -311,6 +310,7 @@ Blockly.BlockSvg.prototype.setCollapsed = function(collapsed) {
|
||||
} else {
|
||||
this.removeInput(COLLAPSED_INPUT_NAME);
|
||||
}
|
||||
Blockly.BlockSvg.superClass_.setCollapsed.call(this, collapsed);
|
||||
|
||||
if (!renderList.length) {
|
||||
// No child blocks, just render this block.
|
||||
|
||||
Reference in New Issue
Block a user