Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TabView: p-tabview-ink-bar doesn't follow the size of TabPanel header property change #10837

Closed
nlachancedev opened this issue Nov 11, 2021 · 2 comments
Assignees
Labels
LTS-PORTABLE Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@nlachancedev
Copy link

Hi

I had some problems with tabView, especially the p-tabview-ink-bar in TabPanel. the p-tabview-ink-bar seems to not follow the size of changed property [header] for a TabPanel. I tested at init (with ngif) and after init (change from input), both seem to not handle it. I found that if I trigger tabView.tabChanged after an [header] update, the p-tabview-ink-bar changes size properly.

For now, I kind of fixed it on my own with a directive tabPanel to manually trigger the tabView.tabChanged (on a settimeout for UI change) when a [header] changes. But maybe the best will be to fix it in the component directly.

My guess maybe is to add the "tabView.tabChanged" at this point: https://github.com/primefaces/primeng/blob/master/src/app/components/tabview/tabview.ts#L123

Thank you.

image

@yigitfindikli yigitfindikli added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working LTS-PORTABLE labels Dec 8, 2021
@yigitfindikli yigitfindikli self-assigned this Dec 8, 2021
@yigitfindikli yigitfindikli added this to the 13.0.3 milestone Dec 8, 2021
@gfragioud
Copy link

@yigitfindikli This change causes "ReferenceError: getComputedStyle is not defined" when tabView is server side rendered, because "setHeader" method calls "updateInkBar" that calls "getComputedStyle" that is undefined at server side.

@x4ahmed
Copy link

x4ahmed commented May 2, 2023

For those who are still having this issue: I had a work around to update the width of the ink-bar based on the width of the container tab:

  1. first inject ChangeDetectorRef to the constructor of the component rendering primeng tab view
  2. constructor(private changeDetectorRef: ChangeDetectorRef) {}
  3. Add AfterViewChecked lifecycle hook to the class
  4. Get current tab element, ink-bar element and set the width to the container width
    `
    ngAfterViewChecked(): void

{

let inkBar = document.getElementsByClassName('p-tabview-ink-bar')[0] as HTMLElement;

let currentTab = document.getElementsByClassName('p-highlight')[0] as HTMLElement;

if(inkBar && currentTab){

  inkBar.style.width = currentTab.clientWidth + 'px';

  this.changeDetectorRef.detectChanges();
} 

}
`

Angular CLI: 15.2.6
Node: 16.17.1
Package Manager: npm 8.15.0
OS: win32 x64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LTS-PORTABLE Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

4 participants