Skip to content

Commit

Permalink
fix: procedure param edits breaking undo (google#5845)
Browse files Browse the repository at this point in the history
  • Loading branch information
BeksOmega authored Jan 4, 2022
1 parent 835fb02 commit 8a71f87
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions core/mutator.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,10 @@ Mutator.prototype.updateWorkspace_ = function() {

// When the mutator's workspace changes, update the source block.
if (this.rootBlock_.workspace === this.workspace_) {
eventUtils.setGroup(true);
const existingGroup = eventUtils.getGroup();
if (!existingGroup) {
eventUtils.setGroup(true);
}
const block = /** @type {!BlockSvg} */ (this.block_);
const oldExtraState = BlockChange.getExtraBlockState_(block);

Expand All @@ -444,11 +447,12 @@ Mutator.prototype.updateWorkspace_ = function() {
eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CHANGE))(
block, 'mutation', null, oldExtraState, newExtraState));
// Ensure that any bump is part of this mutation's event group.
const group = eventUtils.getGroup();
const mutationGroup = eventUtils.getGroup();
setTimeout(function() {
eventUtils.setGroup(group);
const oldGroup = eventUtils.getGroup();
eventUtils.setGroup(mutationGroup);
block.bumpNeighbours();
eventUtils.setGroup(false);
eventUtils.setGroup(oldGroup);
}, internalConstants.BUMP_DELAY);
}

Expand All @@ -457,7 +461,7 @@ Mutator.prototype.updateWorkspace_ = function() {
if (!this.workspace_.isDragging()) {
this.resizeBubble_();
}
eventUtils.setGroup(false);
eventUtils.setGroup(existingGroup);
}
};

Expand Down

0 comments on commit 8a71f87

Please sign in to comment.