fix: undo/redo for auto disabling if-return blocks (#6018)

* fix: undo/redo for auto disabling if-return blocks

* fix: update inline docs
This commit is contained in:
Beka Westberg
2022-03-23 08:48:40 -07:00
committed by GitHub
parent c4308007bc
commit c7a359a842
2 changed files with 12 additions and 10 deletions

View File

@@ -342,7 +342,7 @@ const CONTROL_FLOW_IN_LOOP_CHECK_MIXIN = {
/**
* Called whenever anything on the workspace changes.
* Add warning if this flow block is not nested inside a loop.
* @param {!AbstractEvent} e Change event.
* @param {!AbstractEvent} e Move event.
* @this {Block}
*/
onchange: function(e) {

View File

@@ -1139,11 +1139,12 @@ blocks['procedures_ifreturn'] = {
/**
* Called whenever anything on the workspace changes.
* Add warning if this flow block is not nested inside a loop.
* @param {!AbstractEvent} _e Change event.
* @param {!AbstractEvent} e Move event.
* @this {Block}
*/
onchange: function(_e) {
if (this.workspace.isDragging && this.workspace.isDragging()) {
onchange: function(e) {
if (this.workspace.isDragging && this.workspace.isDragging() ||
e.type !== Events.BLOCK_MOVE) {
return; // Don't change state at the start of a drag.
}
let legal = false;
@@ -1171,14 +1172,15 @@ blocks['procedures_ifreturn'] = {
this.hasReturnValue_ = true;
}
this.setWarningText(null);
if (!this.isInFlyout) {
this.setEnabled(true);
}
} else {
this.setWarningText(Msg['PROCEDURES_IFRETURN_WARNING']);
if (!this.isInFlyout && !this.getInheritedDisabled()) {
this.setEnabled(false);
}
}
if (!this.isInFlyout) {
const group = Events.getGroup();
// Makes it so the move and the disable event get undone together.
Events.setGroup(e.group);
this.setEnabled(legal);
Events.setGroup(group);
}
},
/**