@@ -196,6 +196,7 @@ export class IgxAccordionComponent implements AfterContentInit, AfterViewInit, O
196
196
private _panels ! : QueryList < IgxExpansionPanelComponent > ;
197
197
private _animationSettings ! : ToggleAnimationSettings ;
198
198
private _expandedPanels ! : Set < IgxExpansionPanelComponent > ;
199
+ private _expandingPanels ! : Set < IgxExpansionPanelComponent > ;
199
200
private _destroy$ = new Subject < void > ( ) ;
200
201
private _unsubChildren$ = new Subject < void > ( ) ;
201
202
private _enabledPanels ! : IgxExpansionPanelComponent [ ] ;
@@ -210,6 +211,7 @@ export class IgxAccordionComponent implements AfterContentInit, AfterViewInit, O
210
211
/** @hidden @internal **/
211
212
public ngAfterViewInit ( ) : void {
212
213
this . _expandedPanels = new Set < IgxExpansionPanelComponent > ( this . _panels . filter ( panel => ! panel . collapsed ) ) ;
214
+ this . _expandingPanels = new Set < IgxExpansionPanelComponent > ( ) ;
213
215
this . _panels . changes . pipe ( takeUntil ( this . _destroy$ ) ) . subscribe ( ( ) => {
214
216
this . subToChanges ( ) ;
215
217
} ) ;
@@ -320,28 +322,43 @@ export class IgxAccordionComponent implements AfterContentInit, AfterViewInit, O
320
322
this . _panels . forEach ( panel => {
321
323
panel . contentExpanded . pipe ( takeUntil ( this . _unsubChildren$ ) ) . subscribe ( ( args : IExpansionPanelEventArgs ) => {
322
324
this . _expandedPanels . add ( args . owner ) ;
325
+ this . _expandingPanels . delete ( args . owner ) ;
323
326
const evArgs : IAccordionEventArgs = { ...args , owner : this , panel : args . owner } ;
324
327
this . panelExpanded . emit ( evArgs ) ;
325
328
} ) ;
326
329
panel . contentExpanding . pipe ( takeUntil ( this . _unsubChildren$ ) ) . subscribe ( ( args : IExpansionPanelCancelableEventArgs ) => {
327
330
if ( args . cancel ) {
328
331
return ;
329
332
}
333
+ const evArgs : IAccordionCancelableEventArgs = { ...args , owner : this , panel : args . owner } ;
334
+ this . panelExpanding . emit ( evArgs ) ;
335
+ if ( evArgs . cancel ) {
336
+ args . cancel = true ;
337
+ return ;
338
+ }
330
339
if ( this . singleBranchExpand ) {
331
340
this . _expandedPanels . forEach ( p => {
332
341
if ( ! p . header . disabled ) {
333
342
p . collapse ( ) ;
334
343
}
335
344
} ) ;
336
- }
337
- const evArgs : IAccordionCancelableEventArgs = { ...args , owner : this , panel : args . owner } ;
338
- this . panelExpanding . emit ( evArgs ) ;
339
- if ( evArgs . cancel ) {
340
- args . cancel = true ;
345
+ this . _expandingPanels . forEach ( p => {
346
+ if ( ! p . header . disabled ) {
347
+ if ( ! p . animationSettings . closeAnimation ) {
348
+ p . openAnimationPlayer ?. reset ( ) ;
349
+ }
350
+ if ( ! p . animationSettings . openAnimation ) {
351
+ p . closeAnimationPlayer ?. reset ( ) ;
352
+ }
353
+ p . collapse ( ) ;
354
+ }
355
+ } ) ;
356
+ this . _expandingPanels . add ( args . owner ) ;
341
357
}
342
358
} ) ;
343
359
panel . contentCollapsed . pipe ( takeUntil ( this . _unsubChildren$ ) ) . subscribe ( ( args : IExpansionPanelEventArgs ) => {
344
360
this . _expandedPanels . delete ( args . owner ) ;
361
+ this . _expandingPanels . delete ( args . owner ) ;
345
362
const evArgs : IAccordionEventArgs = { ...args , owner : this , panel : args . owner } ;
346
363
this . panelCollapsed . emit ( evArgs ) ;
347
364
} ) ;
0 commit comments