@@ -145,7 +145,7 @@ export class NotificationManager {
145
145
for ( let i = 0 ; i < this . toaster . length ; i ++ ) {
146
146
this . toaster [ i ] . duration -= deltaTime ;
147
147
if ( this . toaster [ i ] . duration <= 0 ) {
148
- this . removeToasterNotification ( this . toaster [ i ] , i ) ;
148
+ this . removeToasterNotification ( i ) ;
149
149
}
150
150
}
151
151
}
@@ -335,14 +335,23 @@ export class NotificationManager {
335
335
336
336
public snackbar = this . notify ;
337
337
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 ) ;
341
341
}
342
342
private handleToastClose : EventListener = ( e : Event ) => {
343
343
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
+ }
346
355
} ;
347
356
348
357
private createToast ( notification : ToasterNotification ) {
@@ -387,7 +396,7 @@ export class NotificationManager {
387
396
}
388
397
389
398
const notificationEl = this . createToast ( notification ) ;
390
- notificationEl . dataset . id = `${ this . toaster . length } ` ;
399
+ notificationEl . dataset . id = `${ performance . now ( ) } ` ;
391
400
notification . element = notificationEl ;
392
401
393
402
if ( notification ?. duration && ! isNaN ( notification . duration ) ) {
0 commit comments