tabView with *ngIf malfunction
[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
tabView in 10.0.0-rc1 malfunction if using *ngIf.
app.component.html
<p-tabView>
<p-tabPanel header="Header 0">
Content 0
</p-tabPanel>
<p-tabPanel header="Header 1" *ngIf="mode == 1">
Content 1
</p-tabPanel>
<p-tabPanel header="Header 2" *ngIf="mode == 2">
Content 2
</p-tabPanel>
</p-tabView>
<p-button label="Click" (click)="onClick()"></p-button>
app.component.ts
mode = 0;
onClick() {
this.mode++;
}
In this case, firstly 'Header 0' only displays. (mode = 0)
push, button, mode become 1. but, html nothing change. this should be display 'Header 0' and 'Header 1'. (If click 'Header 0', 'Header 1' display). angular 9 work properly.
Please fix this problem, and/or please let me know how to show 'Header 1' manually without user click.
I experience that no dynamic changes from code is reflected, e.g. adding or removing items from a tabs array used in and ng-for statement is not applied either. Referencing the tabview component from code and calling this.tabView.cd.markForCheck() makes the changes get applied, even solves the case above.
I can confirm, using ngFor for dynamic tabs as stated in the documentation does not reflect changes on bound property. Using a ngIf on the p-tabView itself solves the issue for me. Stackblitz
I think i have a similar issue: https://forum.primefaces.org/viewtopic.php?f=35&p=185930#p185930
But this.tabView.cd.markForCheck() does not work for me. @WillooWisp Where do you call this.tabView.cd.markForCheck()? In ngAfterViewInit it does not work
Okay, found a solution for me. This works for me. But of course it is dirty as hell. For me it was important to call markForCheck not immediately.
ngAfterViewInit() {
setTimeout(() => {
this.loginTabView.cd.markForCheck();
}, 100);
}
similar issue hapens for me if you want to display tabs conditionaly with ngIf. If every tabPanel has ngif condition you receive
Error: NG0100: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'undefined'. Current value: 'true'
if you have at least 1 tabpanel without ngIf it works flawlessly
Hi,
So sorry for the delayed response! Improvements have been made to many components recently, both in terms of performance and enhancement. Therefore, this improvement may have been developed in another issue ticket without realizing it. You can check this in the documentation. If there is no improvement on this, can you reopen the issue so we can include it in our roadmap? Please don't forget to add your feedback as a comment after reopening the issue. These will be taken into account by us and will contribute to the development of this feature. Thanks a lot for your understanding!
Best Regards,
Still happens with lazy-loaded tabs in primeNG 14.2.2