primeng icon indicating copy to clipboard operation
primeng copied to clipboard

Tabview try to find li.p-highlight and if it does not find, it crashes

Open fxvits opened this issue 4 years ago • 3 comments

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

We are using Tabview as follow and when the page load the method updateInkBar of the Tabview component is crashing because it tries to get the header element having li.p-highlight class but it does not find it and so when it tries to do DomHandler.getWidth(tabHeader), tabheader is null and then crash

` <p-tabView (onChange)="onTabChanged($event)"> <p-tabPanel [header]="view.DashboardViewTitle" *ngFor="let view of views; let i = index" [selected]="i === 0">

<ng-container *ngIf="selectedView">    
    -- MY DATA
</ng-container>

updateInkBar() { if (this.navbar) { let tabHeader = DomHandler.findSingle(this.navbar.nativeElement, 'li.p-highlight'); this.inkbar.nativeElement.style.width = DomHandler.getWidth(tabHeader) + 'px'; this.inkbar.nativeElement.style.left = DomHandler.getOffset(tabHeader).left - DomHandler.getOffset(this.navbar.nativeElement).left + 'px'; } } `

fxvits avatar Feb 15 '22 12:02 fxvits

Issue is not clear, please feel free to reopen with a stackblitz example.

yigitfindikli avatar Feb 15 '22 12:02 yigitfindikli

If I have time I will create a stackblitz but for me the code is clear. You do not test if tabheader is null if the li.p-highlight class is not found and thus the next line CRASH

fxvits avatar Feb 15 '22 13:02 fxvits

Because I'm kind ;) and I wanna find the best solution for PrimeNG users

Here a stackblitz example : https://angular-ivy-9w8erm.stackblitz.io

fxvits avatar Feb 15 '22 13:02 fxvits