Growl not disappear
Hello,
After updating version 2.0.0 to 4.0.3 growl does not disappear after a few seconds, the definition of the element is:
<p-growl [value] = "msgs"> </ p-growl>
NOTE: It also happens at https://www.primefaces.org/primeng/#/growl
Greetings.
I'm submitting a ... (check one with "x")
[x] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35
Plunkr Case (Bug Reports) Please fork the plunkr below and create a case demonstrating your bug report. Issues without a plunkr have much less possibility to be reviewed.
http://plnkr.co/edit/VZbdZfQ7SuTV87tTkbYR?p=preview
Current behavior
After updating version 2.0.0 to 4.0.3 growl does not disappear after a few seconds
Expected behavior Growl should disappear after 3 seconds
Minimal reproduction of the problem with instructions
It also happens at https://www.primefaces.org/primeng/#/growl
HTML <p-growl [value] = "msgs"> </ p-growl> TS messageService.messageSource$.subscribe( msg => { this.msgs.push(msg); });
What is the motivation / use case for changing the behavior?
Please tell us about your environment:
- Angular version: 4.0.0
- PrimeNG version: 4.0.3
- Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
-
Language: [all | TypeScript X.X | ES6/7 | ES5]
-
Node (for AoT issues):
node --version=
same issue
+1, having the same issue
Brackets are missing for "sticky" input on doc's. This cause the problem on showcase.
In your issue you are not using sticky, so, i can't simulate the problem when sticky is not defined. If you are removed the property to open issue, please use [sticky] with brackets instead of sticky.
hi. I probe with <p-growl [value]="msgs" [sticky]="true"> but didn´t work
@sourdoth
When strick if defined, growl messages are not removed automatically after a period defined by life option. Please change to false or remove the attr
@upmauro When will be the next release version with current fix ?
@CatherineBorykina in actual release this works, but you need use brackets in [sticky] attribute with false value or remove this attribute.
@upmauro I try with:
<p-growl [value]="msgs" > <p-growl [value]="msgs" [sticky]="false"> <p-growl [value]="msgs" sticky="false"> <p-growl [value]="msgs" [sticky]="true"> <p-growl [value]="msgs" sticky="true"> <p-growl [value]="msgs" [sticky]="false" life="3000"> <p-growl [value]="msgs" [sticky]="false" [life]="3000"> <p-growl [value]="msgs" [sticky]="true" [life]="3000"> <p-growl [value]="msgs" [life]="3000"> <p-growl [value]="msgs" life="3000">
but growl not disappear
@upmauro No, it doesn't work on version 4.0.3. Either with or without [sticky] attribute. <p-growl class="here" [value]="msgs" > <p-growl class="here" [value]="msgs" [sticky]="false"> But it works fine, if I downgrade my primeng version to 2.0.0
@upmauro I try with:
<p-growl [value]="msgs" > <p-growl [value]="msgs" [sticky]="false"> <p-growl [value]="msgs" sticky="false"> <p-growl [value]="msgs" [sticky]="true"> <p-growl [value]="msgs" sticky="true"> <p-growl [value]="msgs" [sticky]="false" life="3000"> <p-growl [value]="msgs" [sticky]="false" [life]="3000"> <p-growl [value]="msgs" [sticky]="true" [life]="3000"> <p-growl [value]="msgs" [life]="3000"> <p-growl [value]="msgs" life="3000">
but growl not disappear
I'm haaving the same issue even on v 4.0.3
perhaps 'Good Bye DoCheck' is the reason that causes this issue,please see: https://www.primefaces.org/primeng-4-0-0-rc4-released/ so, assign a new array data to msgs,or like this: this.msgs = []; this.msgs.push({severity: 'error', summary: 'Error Message', detail: 'please disappear automatically'}); it will work well.
hi. perfect i just add this.msgs = []; and work thanks.
So, no need to clear, but one can just serialize/deserialize to make that work, e.g.:
this.messages.push({ severity: 'error', summary: 'some error', detail: 'error description' });
this.messages = JSON.parse(JSON.stringify(this.messages));
Though i don't think this is a correct behavior overall
This does not work for me in 4.0.1. It used to work for me before upgrading to Angular 4 and PrimeNg 4
<p-growl [(value)]="this.msgs" [life]="3000" [sticky]="false"></p-growl>
<p-growl [(value)]="this.errorMsgs" [sticky]="true"></p-growl>
ngOnInit() {
this.msgs = [];
this.errorMsgs = [];
this.messageservice.msgs$.subscribe((messages: Message[]) => {
messages.forEach((message: Message) => {
if (message.severity === 'error') {
this.errorMsgs.push(message);
} else {
this.msgs.push(message);
}
});
});
}
Same issue here, works in "primeng": "4.0.0-rc.1", doesn't work in newer versions:
<p-growl [value]="msgs"></p-growl>
ngOnInit() {
this.appNotificationService.getMessage().subscribe(
(data: Message) => this.msgs.push(data)
);
}>
@Injectable()
export class ApplicationNotificationService {
private subject: Subject<Message> = new Subject<Message>();
setError(detail: any) {
let message = '';
if (typeof detail === 'string') {
message = detail;
} else if (typeof detail === 'object' && !!detail['msg']) {
message = detail['msg'];
}
this.subject.next({ severity: 'error', summary: 'Greška', detail: message });
}
setMessage(severity: string, detail: string, summary?: string, ): void {
this.subject.next({ severity: severity, summary: summary, detail: detail });
}
passMessage(message: string): void {
this.subject.next({ severity: 'info', summary: 'Transakcija uspješna', detail: message });
}
getMessage(): Observable<Message> {
return this.subject.asObservable();
}
}
@ajambrovic @gregkopp
Have you read the answers above at all?
use this.messages = JSON.parse(JSON.stringify(this.messages));
or
this.growl = [...this.growl, {severity: severity, summary: summary, detail: text}];
@cyberrranger - I did, they are:
- Use sticky/life explicitly - doesn't work
- Clear messages - can't do that since it would only show the last message
- The downvoted @VagrantAI-c comment (which you refer to) - looks like a hack
I suppose num 3. would work, but I was hoping for a cleaner solution (not to mention that I'm confused as to why something that worked up to (and including) 4.0.0-rc.1, doesn't work.
@ajambrovic i use 4.1.0-rc.2
and without problems
this.growl = [...this.growl, {severity: severity, summary: summary, detail: text}];
<p-growl [(value)]="growl" life="5000"></p-growl>
Hi all, I also have this problems. I fixed it with a workaround. I have a message service where the messages are stored and I have a lot of utility methods to add msgs. When I add a message I also call an internal function with a timeout that clear the messages lists.
This is my utility method (obviously I have a msgs variable in my service):
addMsg(severity: string, msg: string, detail: string = '') {
this.msgs.push({severity: severity, summary: msg, detail: detail});
this.setHideTimeout();
}
and this is the simply timeout function
setHideTimeout() {
setTimeout(() => {
this.msgs = [];
}, 5000);
}
And at the end on my component
<p-growl [value]="msgSvc.msgs()" ></p-growl>
It seems to works fine, hope this could be useful for someone.
Have a good day Fabrizio
@fplini ist a different [(value)] and [value], show my answer