primeng icon indicating copy to clipboard operation
primeng copied to clipboard

TabView "activeIndex" not working for dynamically created tabs

Open parisgianluca opened this issue 8 years ago • 6 comments

I'm submitting a ...

[ 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

Current behavior If the tabs of the tab view are created dynamically (e.g. using an *ngFor), activeIndex won't work

Expected behavior ActiveIndex should work even with dynamically generated tabs

What is the motivation / use case for changing the behavior? It does not work as promised

  • PrimeNG version: 5.2.0

  • Browser: all

parisgianluca avatar May 17 '18 13:05 parisgianluca

I'm also running into this with v6.0.1.

bniedermeyer avatar Aug 06 '18 21:08 bniedermeyer

I'm also running into this with v6.1.0. any update on this one?

ohadzu avatar Sep 12 '18 08:09 ohadzu

I'm unable to replicate with the latest PrimeNG. If the issue still persists with the new version please create a new issue with our stackblitz template.

cagataycivici avatar Jan 03 '19 14:01 cagataycivici

I'm running into an issue:

TabPanel.html:2 ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'ui-helper-hidden: true'. Current value: 'ui-helper-hidden: false'. at viewDebugError (core.js:19006) at expressionChangedAfterItHasBeenCheckedError (core.js:18994) at checkBindingNoChanges (core.js:19096) at checkNoChangesNodeInline (core.js:21967) at checkNoChangesNode (core.js:21956) at debugCheckNoChangesNode (core.js:22560) at debugCheckDirectivesFn (core.js:22488) at Object.eval [as updateDirectives] (TabPanel.html:2) at Object.debugUpdateDirectives [as updateDirectives] (core.js:22477) at checkNoChangesView (core.js:21855)

<p-tabView [activeIndex]="openedIdx" [controlClose]="true" (onClose)="handleClose($event)" (onChange)="handleChange($event)"> <p-tabPanel [header]="item.name" [closable]="true" *ngFor="let item of items;"> <div #editor id="editor-div" ace-editor [(text)]="item.content" [mode]="'sql'" [theme]="'eclipse'" [options]="options" [readOnly]="false" [autoUpdateContent]="true" [durationBeforeCallback]="1000" (textChanged)="onEditorTextChange($event)" style="min-height: 200px; width:100%; overflow: auto;"> </div> </p-tabPanel> </p-tabView>

export class TabbedEditorComponent implements OnInit { @ViewChild('editor') editor: AceEditorComponent; // tslint:disable-next-line:member-ordering text = 'Test'; openedIdx: number; ..... }

PrimeNG Version: "primeicons": "^1.0.0", "primeng": "^7.0.5",

Thaval avatar Feb 17 '19 13:02 Thaval

Hey @cagataycivici, I'm running the same issue with v13. Please take a look at this stackblitz example. I used two p-tabViews. The first one has dynamic number of p-tabPanels, while the other has static number of panels. I purposely set currentTab to 3 in ngOnInit so that I can select 4th tab - it gets selected in the second p-tabView, while it doesn't in the first.

Any chance to take a further investigation about this issue?

jakovljevic-mladen avatar Feb 24 '22 20:02 jakovljevic-mladen

Hi! I have the same exact issue with version 13.4.1, there's no way I can set the active index with dynamically created tabs. Any plans on solving this? I can select the tabs with the selected field but the moment you navigate away of the tab and it gets selected again the tabview does not navigate to the newly selected one so you can't see it. thanks!

AlejandraMorenoBS avatar Nov 22 '22 16:11 AlejandraMorenoBS