mirror of
https://github.com/google/blockly.git
synced 2026-01-08 17:40:09 +01:00
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:
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
},
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user