mirror of
https://github.com/google/blockly.git
synced 2026-01-08 01:20:12 +01:00
Fixed adding a variable field programmatically when it has a following field. (#3468)
* Fixed adding a var field through mutator error.
This commit is contained in:
committed by
Sam El-Husseini
parent
17fa526e0e
commit
78e2fb2f4b
@@ -147,11 +147,8 @@ Blockly.FieldVariable.prototype.initModel = function() {
|
||||
this.sourceBlock_.workspace, null,
|
||||
this.defaultVariableName, this.defaultType_);
|
||||
|
||||
// Don't fire a change event for this setValue. It would have null as the
|
||||
// old value, which is not valid.
|
||||
Blockly.Events.disable();
|
||||
this.setValue(variable.getId());
|
||||
Blockly.Events.enable();
|
||||
// Don't call setValue because we don't want to cause a rerender.
|
||||
this.doValueUpdate_(variable.getId());
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -372,15 +372,10 @@ Blockly.Mutator.prototype.workspaceChanged_ = function(e) {
|
||||
var block = this.block_;
|
||||
var oldMutationDom = block.mutationToDom();
|
||||
var oldMutation = oldMutationDom && Blockly.Xml.domToText(oldMutationDom);
|
||||
// Switch off rendering while the source block is rebuilt.
|
||||
var savedRendered = block.rendered;
|
||||
block.rendered = false;
|
||||
// Allow the source block to rebuild itself.
|
||||
block.compose(this.rootBlock_);
|
||||
// Restore rendering and show the changes.
|
||||
block.rendered = savedRendered;
|
||||
// Mutation may have added some elements that need initializing.
|
||||
block.initSvg();
|
||||
block.render();
|
||||
var newMutationDom = block.mutationToDom();
|
||||
var newMutation = newMutationDom && Blockly.Xml.domToText(newMutationDom);
|
||||
if (oldMutation != newMutation) {
|
||||
@@ -394,9 +389,6 @@ Blockly.Mutator.prototype.workspaceChanged_ = function(e) {
|
||||
Blockly.Events.setGroup(false);
|
||||
}, Blockly.BUMP_DELAY);
|
||||
}
|
||||
if (block.rendered) {
|
||||
block.render();
|
||||
}
|
||||
|
||||
if (oldMutation != newMutation &&
|
||||
this.workspace_.keyboardAccessibilityMode) {
|
||||
|
||||
Reference in New Issue
Block a user