File tree Expand file tree Collapse file tree 2 files changed +30
-3
lines changed
Expand file tree Collapse file tree 2 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -539,12 +539,22 @@ export class BlockSvg
539539 * @returns true if any child has a warning, false otherwise.
540540 */
541541 private childHasWarning ( ) : boolean {
542- const children = this . getChildren ( false ) ;
543- for ( const child of children ) {
544- if ( child . getIcon ( WarningIcon . TYPE ) || child . childHasWarning ( ) ) {
542+ const next = this . getNextBlock ( ) ;
543+ const excluded = next ? new Set ( next . getDescendants ( false ) ) : null ;
544+ const descendants = this . getDescendants ( false ) ;
545+
546+ for ( const descendant of descendants ) {
547+ if ( descendant === this ) {
548+ continue ;
549+ }
550+ if ( excluded ?. has ( descendant ) ) {
551+ continue ;
552+ }
553+ if ( descendant . getIcon ( WarningIcon . TYPE ) ) {
545554 return true ;
546555 }
547556 }
557+
548558 return false ;
549559 }
550560
Original file line number Diff line number Diff line change @@ -1950,6 +1950,23 @@ suite('Blocks', function () {
19501950 'Warning should be removed from parent after expanding' ,
19511951 ) ;
19521952 } ) ;
1953+
1954+ test ( 'Collapsing a block should not inherit warnings from following siblings' , function ( ) {
1955+ const nextBlock = createRenderedBlock (
1956+ this . workspace ,
1957+ 'statement_block' ,
1958+ ) ;
1959+ this . childBlock . nextConnection . connect ( nextBlock . previousConnection ) ;
1960+ nextBlock . setWarningText ( 'Warning Text' ) ;
1961+
1962+ this . childBlock . setCollapsed ( true ) ;
1963+
1964+ const icon = this . childBlock . getIcon ( Blockly . icons . WarningIcon . TYPE ) ;
1965+ assert . isUndefined (
1966+ icon ,
1967+ 'Collapsed block should not show warnings from following siblings' ,
1968+ ) ;
1969+ } ) ;
19531970 } ) ;
19541971
19551972 suite ( 'Bubbles and collapsing' , function ( ) {
You can’t perform that action at this time.
0 commit comments