From a4d97c2f18d8a742a3c82bb8826b3ef607212f8e Mon Sep 17 00:00:00 2001 From: joey Date: Tue, 13 Jan 2026 16:26:45 +0000 Subject: [PATCH] fix: collapsed warning propagation across siblings (#9566) (#9567) --- core/block_svg.ts | 16 +++++++++++++--- tests/mocha/block_test.js | 17 +++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/core/block_svg.ts b/core/block_svg.ts index b3fdeb2d6..83af5188e 100644 --- a/core/block_svg.ts +++ b/core/block_svg.ts @@ -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; } diff --git a/tests/mocha/block_test.js b/tests/mocha/block_test.js index 22d865d79..9c306a740 100644 --- a/tests/mocha/block_test.js +++ b/tests/mocha/block_test.js @@ -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 () {