mirror of
https://github.com/google/blockly.git
synced 2026-02-12 02:20:10 +01:00
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
Reference in New Issue
Block a user