@@ -560,31 +560,35 @@ export class NotificationsToasts extends Themable implements INotificationsToast
560560 availableHeight -= ( 2 * 12 ) ; // adjust for paddings top and bottom
561561 }
562562
563- availableHeight = typeof availableHeight === 'number'
564- ? Math . round ( availableHeight * 0.618 ) // try to not cover the full height for stacked toasts
565- : 0 ;
566-
567- return new Dimension ( Math . min ( maxWidth , availableWidth ) , availableHeight ) ;
563+ return new Dimension ( Math . min ( maxWidth , availableWidth ) , availableHeight ?? 0 ) ;
568564 }
569565
570566 private layoutLists ( width : number ) : void {
571567 this . mapNotificationToToast . forEach ( ( { list } ) => list . layout ( width ) ) ;
572568 }
573569
574570 private layoutContainer ( heightToGive : number ) : void {
571+
572+ // Allow the full height for 1 toast but adjust for multiple toasts
573+ // so that a stack of notifications does not exceed all the way up
574+
575+ let singleToastHeightToGive = heightToGive ;
576+ let multipleToastsHeightToGive = Math . round ( heightToGive * 0.618 ) ;
577+
575578 let visibleToasts = 0 ;
576579 for ( const toast of this . getToasts ( ToastVisibility . HIDDEN_OR_VISIBLE ) ) {
577580
578581 // In order to measure the client height, the element cannot have display: none
579582 toast . container . style . opacity = '0' ;
580583 this . updateToastVisibility ( toast , true ) ;
581584
582- heightToGive -= toast . container . offsetHeight ;
585+ singleToastHeightToGive -= toast . container . offsetHeight ;
586+ multipleToastsHeightToGive -= toast . container . offsetHeight ;
583587
584588 let makeVisible = false ;
585589 if ( visibleToasts === NotificationsToasts . MAX_NOTIFICATIONS ) {
586590 makeVisible = false ; // never show more than MAX_NOTIFICATIONS
587- } else if ( heightToGive >= 0 ) {
591+ } else if ( ( visibleToasts === 0 && singleToastHeightToGive >= 0 ) || ( visibleToasts > 0 && multipleToastsHeightToGive >= 0 ) ) {
588592 makeVisible = true ; // hide toast if available height is too little
589593 }
590594
0 commit comments