mirror of
https://github.com/google/blockly.git
synced 2026-01-04 15:40:08 +01:00
fix: Don't record undo events for enable/disable (#8058)
There's no need to record and replay these events since the change will happen automatically anyway. Resolves #7951
This commit is contained in:
@@ -20,6 +20,7 @@ import {
|
|||||||
createBlockDefinitionsFromJsonArray,
|
createBlockDefinitionsFromJsonArray,
|
||||||
defineBlocks,
|
defineBlocks,
|
||||||
} from '../core/common.js';
|
} from '../core/common.js';
|
||||||
|
import * as eventUtils from '../core/events/utils.js';
|
||||||
import '../core/field_dropdown.js';
|
import '../core/field_dropdown.js';
|
||||||
import '../core/field_label.js';
|
import '../core/field_label.js';
|
||||||
import '../core/field_number.js';
|
import '../core/field_number.js';
|
||||||
@@ -381,15 +382,19 @@ const CONTROL_FLOW_IN_LOOP_CHECK_MIXIN = {
|
|||||||
this.setWarningText(
|
this.setWarningText(
|
||||||
enabled ? null : Msg['CONTROLS_FLOW_STATEMENTS_WARNING'],
|
enabled ? null : Msg['CONTROLS_FLOW_STATEMENTS_WARNING'],
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!this.isInFlyout) {
|
if (!this.isInFlyout) {
|
||||||
const group = Events.getGroup();
|
try {
|
||||||
// Makes it so the move and the disable event get undone together.
|
// There is no need to record the enable/disable change on the undo/redo
|
||||||
Events.setGroup(e.group);
|
// list since the change will be automatically recreated when replayed.
|
||||||
this.setDisabledReason(
|
eventUtils.setRecordUndo(false);
|
||||||
!enabled,
|
this.setDisabledReason(
|
||||||
CONTROL_FLOW_NOT_IN_LOOP_DISABLED_REASON,
|
!enabled,
|
||||||
);
|
CONTROL_FLOW_NOT_IN_LOOP_DISABLED_REASON,
|
||||||
Events.setGroup(group);
|
);
|
||||||
|
} finally {
|
||||||
|
eventUtils.setRecordUndo(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import type {
|
|||||||
ContextMenuOption,
|
ContextMenuOption,
|
||||||
LegacyContextMenuOption,
|
LegacyContextMenuOption,
|
||||||
} from '../core/contextmenu_registry.js';
|
} from '../core/contextmenu_registry.js';
|
||||||
|
import * as eventUtils from '../core/events/utils.js';
|
||||||
import {FieldCheckbox} from '../core/field_checkbox.js';
|
import {FieldCheckbox} from '../core/field_checkbox.js';
|
||||||
import {FieldLabel} from '../core/field_label.js';
|
import {FieldLabel} from '../core/field_label.js';
|
||||||
import {FieldTextInput} from '../core/field_textinput.js';
|
import {FieldTextInput} from '../core/field_textinput.js';
|
||||||
@@ -1329,12 +1330,16 @@ const PROCEDURES_IFRETURN = {
|
|||||||
} else {
|
} else {
|
||||||
this.setWarningText(Msg['PROCEDURES_IFRETURN_WARNING']);
|
this.setWarningText(Msg['PROCEDURES_IFRETURN_WARNING']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.isInFlyout) {
|
if (!this.isInFlyout) {
|
||||||
const group = Events.getGroup();
|
try {
|
||||||
// Makes it so the move and the disable event get undone together.
|
// There is no need to record the enable/disable change on the undo/redo
|
||||||
Events.setGroup(e.group);
|
// list since the change will be automatically recreated when replayed.
|
||||||
this.setDisabledReason(!legal, UNPARENTED_IFRETURN_DISABLED_REASON);
|
eventUtils.setRecordUndo(false);
|
||||||
Events.setGroup(group);
|
this.setDisabledReason(!legal, UNPARENTED_IFRETURN_DISABLED_REASON);
|
||||||
|
} finally {
|
||||||
|
eventUtils.setRecordUndo(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user