@@ -145,7 +145,7 @@ export class NotificationManager {
145145 for ( let i = 0 ; i < this . toaster . length ; i ++ ) {
146146 this . toaster [ i ] . duration -= deltaTime ;
147147 if ( this . toaster [ i ] . duration <= 0 ) {
148- this . removeToasterNotification ( this . toaster [ i ] , i ) ;
148+ this . removeToasterNotification ( i ) ;
149149 }
150150 }
151151 }
@@ -335,14 +335,23 @@ export class NotificationManager {
335335
336336 public snackbar = this . notify ;
337337
338- private removeToasterNotification ( notification : ToasterNotification , id : number ) {
339- notification . element . remove ( ) ;
340- this . toaster . splice ( id , 1 ) ;
338+ private removeToasterNotification ( index : number ) {
339+ this . toaster [ index ] . element . remove ( ) ;
340+ this . toaster . splice ( index , 1 ) ;
341341 }
342342 private handleToastClose : EventListener = ( e : Event ) => {
343343 const target = e . currentTarget as HTMLButtonElement ;
344- const id = parseInt ( target . parentElement . dataset . id ) ;
345- this . removeToasterNotification ( this . toaster [ id ] , id ) ;
344+ const notificationId = target . parentElement . dataset . id ;
345+ let index = null ;
346+ for ( let i = 0 ; i < this . toaster . length ; i ++ ) {
347+ if ( this . toaster [ i ] . element . dataset . id === notificationId ) {
348+ index = i ;
349+ break ;
350+ }
351+ }
352+ if ( index ) {
353+ this . removeToasterNotification ( index ) ;
354+ }
346355 } ;
347356
348357 private createToast ( notification : ToasterNotification ) {
@@ -387,7 +396,7 @@ export class NotificationManager {
387396 }
388397
389398 const notificationEl = this . createToast ( notification ) ;
390- notificationEl . dataset . id = `${ this . toaster . length } ` ;
399+ notificationEl . dataset . id = `${ performance . now ( ) } ` ;
391400 notification . element = notificationEl ;
392401
393402 if ( notification ?. duration && ! isNaN ( notification . duration ) ) {
0 commit comments