fix: collapsed warning propagation across siblings (#9566) (#9567)

This commit is contained in:
joey
2026-01-13 16:26:45 +00:00
committed by GitHub
parent c79273a351
commit a4d97c2f18
2 changed files with 30 additions and 3 deletions

View File

@@ -539,12 +539,22 @@ export class BlockSvg
* @returns true if any child has a warning, false otherwise.
*/
private childHasWarning(): boolean {
const children = this.getChildren(false);
for (const child of children) {
if (child.getIcon(WarningIcon.TYPE) || child.childHasWarning()) {
const next = this.getNextBlock();
const excluded = next ? new Set(next.getDescendants(false)) : null;
const descendants = this.getDescendants(false);
for (const descendant of descendants) {
if (descendant === this) {
continue;
}
if (excluded?.has(descendant)) {
continue;
}
if (descendant.getIcon(WarningIcon.TYPE)) {
return true;
}
}
return false;
}

View File

@@ -1950,6 +1950,23 @@ suite('Blocks', function () {
'Warning should be removed from parent after expanding',
);
});
test('Collapsing a block should not inherit warnings from following siblings', function () {
const nextBlock = createRenderedBlock(
this.workspace,
'statement_block',
);
this.childBlock.nextConnection.connect(nextBlock.previousConnection);
nextBlock.setWarningText('Warning Text');
this.childBlock.setCollapsed(true);
const icon = this.childBlock.getIcon(Blockly.icons.WarningIcon.TYPE);
assert.isUndefined(
icon,
'Collapsed block should not show warnings from following siblings',
);
});
});
suite('Bubbles and collapsing', function () {