mirror of
https://github.com/google/blockly.git
synced 2025-12-15 22:00:07 +01:00
fix: improve prompting when deleting variables (#8529)
* fix: improve variable deletion behaviors. * fix: don't prompt about deletion of only 1 variable block when triggered programmatically. * fix: include the triggering block in the count of referencing blocks * fix: only count the triggering block as a referencing block if it's not in the flyout
This commit is contained in:
@@ -165,11 +165,12 @@ const deleteOptionCallbackFactory = function (
|
||||
block: VariableBlock,
|
||||
): () => void {
|
||||
return function () {
|
||||
const workspace = block.workspace;
|
||||
const variableField = block.getField('VAR') as FieldVariable;
|
||||
const variable = variableField.getVariable()!;
|
||||
workspace.deleteVariableById(variable.getId());
|
||||
(workspace as WorkspaceSvg).refreshToolboxSelection();
|
||||
const variable = variableField.getVariable();
|
||||
if (variable) {
|
||||
Variables.deleteVariable(variable.getWorkspace(), variable, block);
|
||||
}
|
||||
(block.workspace as WorkspaceSvg).refreshToolboxSelection();
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -176,11 +176,12 @@ const renameOptionCallbackFactory = function (block: VariableBlock) {
|
||||
*/
|
||||
const deleteOptionCallbackFactory = function (block: VariableBlock) {
|
||||
return function () {
|
||||
const workspace = block.workspace;
|
||||
const variableField = block.getField('VAR') as FieldVariable;
|
||||
const variable = variableField.getVariable()!;
|
||||
workspace.deleteVariableById(variable.getId());
|
||||
(workspace as WorkspaceSvg).refreshToolboxSelection();
|
||||
const variable = variableField.getVariable();
|
||||
if (variable) {
|
||||
Variables.deleteVariable(variable.getWorkspace(), variable, block);
|
||||
}
|
||||
(block.workspace as WorkspaceSvg).refreshToolboxSelection();
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user