From 0ede135ae5ec90a73c2724ea6ef8906efa8f63f3 Mon Sep 17 00:00:00 2001 From: Davide Menegatti Date: Tue, 23 May 2023 09:30:57 +0200 Subject: [PATCH] Fix #13079 - ToastCloseEvent types --- src/app/components/toast/toast.interface.ts | 7 ++----- src/app/components/toast/toast.ts | 8 ++++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/app/components/toast/toast.interface.ts b/src/app/components/toast/toast.interface.ts index 5177abbf1d8..aec83a805be 100644 --- a/src/app/components/toast/toast.interface.ts +++ b/src/app/components/toast/toast.interface.ts @@ -1,5 +1,6 @@ import { TemplateRef } from '@angular/core'; import { Toast } from './toast'; +import { Message } from '../api/message'; /** * Breakpoints of toast element. */ @@ -33,9 +34,5 @@ export interface ToastCloseEvent { /** * Message of the closed element. */ - message?: string; - /** - * Index of the removed element. - */ - index?: number; + message: Message; } diff --git a/src/app/components/toast/toast.ts b/src/app/components/toast/toast.ts index d59b0ec99f8..92a4380294f 100755 --- a/src/app/components/toast/toast.ts +++ b/src/app/components/toast/toast.ts @@ -98,9 +98,9 @@ import { ToastBreakpoints, ToastCloseEvent } from './toast.interface'; } }) export class ToastItem implements AfterViewInit, OnDestroy { - @Input() message: Message | null | undefined; + @Input({required: true}) message!: Message; - @Input() index: number | undefined; + @Input({required: true}) index!: number; @Input() template: TemplateRef | undefined; @@ -112,7 +112,7 @@ export class ToastItem implements AfterViewInit, OnDestroy { @Input() hideTransitionOptions: string | undefined; - @Output() onClose: EventEmitter = new EventEmitter(); + @Output() onClose: EventEmitter<{message: Message, index: number}> = new EventEmitter(); @ViewChild('container') containerViewChild: ElementRef | undefined; @@ -370,7 +370,7 @@ export class Toast implements OnInit, AfterContentInit, OnDestroy { }); } - onMessageClose(event: any) { + onMessageClose(event: {message: Message, index: number}) { this.messages?.splice(event.index, 1); this.onClose.emit({