Skip to content

Commit

Permalink
Merge pull request #15088 from primefaces/issue-14982
Browse files Browse the repository at this point in the history
Fixed #14982 - Messages | Add onClose emitter
  • Loading branch information
cetincakiroglu authored Mar 19, 2024
2 parents 1d69273 + 539e39f commit f26e38f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/app/components/messages/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ export class Messages implements AfterContentInit, OnDestroy {
* @group Emits
*/
@Output() valueChange: EventEmitter<Message[]> = new EventEmitter<Message[]>();
/**
* This function is executed when a message is closed.
* @param {Message} value - Closed message.
* @group Emits
*/
@Output() onClose: EventEmitter<Message> = new EventEmitter<Message>();

@ContentChildren(PrimeTemplate) templates: QueryList<PrimeTemplate> | undefined;

Expand Down Expand Up @@ -203,6 +209,7 @@ export class Messages implements AfterContentInit, OnDestroy {

removeMessage(i: number) {
this.messages = this.messages?.filter((msg, index) => index !== i);
this.messages[i] && this.onClose.emit(this.messages[i]);
this.valueChange.emit(this.messages);
}

Expand Down

0 comments on commit f26e38f

Please sign in to comment.