primeng icon indicating copy to clipboard operation
primeng copied to clipboard

accordion tabs are opened after dialog close

Open majkers opened this issue 4 years ago • 14 comments

Describe the bug

Everything is written in https://github.com/primefaces/primeng/issues/9453

Environment

in issue https://github.com/primefaces/primeng/issues/9453

Reproducer

https://stackblitz.com/edit/primeng-dialog-accordion-problem-tqtn9k?file=package.json

Angular version

14.2.10

PrimeNG version

14.2.1

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

14.17.3

Browser(s)

All

Steps to reproduce the behavior

in issue https://github.com/primefaces/primeng/issues/9453

Expected behavior

in issue https://github.com/primefaces/primeng/issues/9453

majkers avatar Nov 10 '22 08:11 majkers

I noticed something similar for DynamicDialog and Dialog in v15/v16 with Accordion and Panel. When the dynamic dialog is opened, all tabs are quickly expanded and then collapses after a few milliseconds.

When closing the dynamic dialog, all the tabs are re-expanded again before it disappears. It may be hard to see because it happens so quickly.

I was hoping the accordion would remain collapsed the entire time unless the user actually clicks the tabs.

Here is a forked example based off the DynamicDialog docs for v16, but I replaced p-table with p-accordion: https://stackblitz.com/edit/luvqct?file=src%2Fapp%2Fdemo%2Fproductlistdemo.ts

mlieu avatar Aug 30 '23 14:08 mlieu

The error is still present in primeng v17.16.1. Using an accordion in a dialog leads to inconsistent behavior. When closing the dialog, the accordion expands all tabs for a few milliseconds before closing, and when reopening the dialog, the tabs are open. Checkout this simple example.

riorudo avatar May 13 '24 09:05 riorudo

Issue also exists if you're using p-sidebar component. Opening a sidebar on the second attempt will open all the accordions.

Demo: https://stackblitz.com/edit/z4x4wd

bvx5009 avatar May 14 '24 20:05 bvx5009

Still happening with v17.18.0, it's so annoying

sarudev avatar Jul 13 '24 05:07 sarudev

Le problème existe également si vous utilisez le composant p-sidebar. L'ouverture d'une barre latérale à la deuxième tentative ouvrira tous les accordéons.

Démo : https://stackblitz.com/edit/z4x4wd

I confirm bug with sidebar. How resolve this? I'm at version 17.18.4.

Tom-DevWeb avatar Jul 18 '24 09:07 Tom-DevWeb

Le problème existe également si vous utilisez le composant p-sidebar. L'ouverture d'une barre latérale à la deuxième tentative ouvrira tous les accordéons. Démo : https://stackblitz.com/edit/z4x4wd

I confirm bug with sidebar. How resolve this? I'm at version 17.18.4.

for a work around I've used a skeleton loader with a setTimeout function. On hide, set the loader to true and on show set it to false after small amount of time allowing items to render properly inside the p-sidebar.

public onPanelClick(): void {
 //we use signal in the template for the visible property that can be opened from x amount of places
  this.myService.showSidebar();
  setTimeout(() => {
    this.loading = false;
  }, 350);
}
 public onHideSidebarClick(): void {
    this.myService.hideSidebar();
    this.loading = true;
  }

bvx5009 avatar Jul 18 '24 13:07 bvx5009

This is still happening to me on angular 18.2.7 and primeng 17.18.9

for a p-accordion inside a p-dialog, when the dialog closes then opens again, all accordions inside it are fully expanded.

Here's an example, first time opening the dialog (looks good) image

close the dialog then reopen it... all accordions are expanded! and the tiny arrow directions are all wrong! image

Ar-Kareem avatar Nov 08 '24 16:11 Ar-Kareem

I can confirm it's still happening in v18 of primeng as well

JamesTheTerry avatar Dec 13 '24 08:12 JamesTheTerry

Still an issue in 18.0.2.

Also maybe related: When opening a popover after having closed it then the accordions inside will be wrongly expanded. Seems like popover caches its content, but there is something wrong in the de-/serialization of the accordion state? Not sure..

BeGj avatar Jan 07 '25 10:01 BeGj

This problem still persists in prime ng 19 version.

hilaltrhaan avatar Jan 13 '25 13:01 hilaltrhaan

My workaround (on v19.0.5) with the use of TailwindCSS, if it helps anyone:

<p-accordion [value]="1">

    <p-accordion-panel [value]="1" class="!h-0 [&.p-accordionpanel-active]:!h-auto">

        <p-accordion-content>
            Content here
        </p-accordion-content>

    </p-accordion-panel>

</p-accordion>

Note: You'll lose the "smooth" closing animation, that's because the p-accordionpanel-active class is applied before the animation finishes and so the override !h-0 will take effect immediately. The opening animation still works.

devidevio avatar Jan 26 '25 23:01 devidevio

v19.1.3: When I wrap my dialog content in <ng-template #content></ng-template> the accordion panel content is only visible for a short moment.

I wrote a small angular directive to hide the accordion panel content initially for a short moment as a temporary workaround. It does not help when closing the dialog, but it solves the very obvious layout shift when opening the dialog.

import { Directive, ElementRef, inject, OnInit } from '@angular/core'

@Directive({
  selector: '[appFixAccordionPanelInDialog]',
  host: { style: 'display: none' },
})
export class FixAccordionPanelInDialogDirective implements OnInit {
  host = inject(ElementRef)

  ngOnInit(): void {
    setTimeout(() => (this.host.nativeElement.style.display = 'inherit'), 250)
  }
}
<p-accordion-content appFixAccordionPanelInDialog>Content</p-accordion-content>

leonlaser avatar Jun 26 '25 12:06 leonlaser

I am also experiencing this issue on v20.2

anthony-b-dev avatar Oct 10 '25 12:10 anthony-b-dev

idem on v19

acathon avatar Oct 27 '25 21:10 acathon