@@ -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,44 @@ 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
+ this . _expandedPanels . delete ( args . owner ) ;
338
+ return ;
339
+ }
330
340
if ( this . singleBranchExpand ) {
331
341
this . _expandedPanels . forEach ( p => {
332
342
if ( ! p . header . disabled ) {
333
343
p . collapse ( ) ;
334
344
}
335
345
} ) ;
336
- }
337
- const evArgs : IAccordionCancelableEventArgs = { ...args , owner : this , panel : args . owner } ;
338
- this . panelExpanding . emit ( evArgs ) ;
339
- if ( evArgs . cancel ) {
340
- args . cancel = true ;
346
+ this . _expandingPanels . forEach ( p => {
347
+ if ( ! p . header . disabled ) {
348
+ if ( ! p . animationSettings . closeAnimation ) {
349
+ p . openAnimationPlayer ?. reset ( ) ;
350
+ }
351
+ if ( ! p . animationSettings . openAnimation ) {
352
+ p . closeAnimationPlayer ?. reset ( ) ;
353
+ }
354
+ p . collapse ( ) ;
355
+ }
356
+ } ) ;
357
+ this . _expandingPanels . add ( args . owner ) ;
341
358
}
342
359
} ) ;
343
360
panel . contentCollapsed . pipe ( takeUntil ( this . _unsubChildren$ ) ) . subscribe ( ( args : IExpansionPanelEventArgs ) => {
344
361
this . _expandedPanels . delete ( args . owner ) ;
362
+ this . _expandingPanels . delete ( args . owner ) ;
345
363
const evArgs : IAccordionEventArgs = { ...args , owner : this , panel : args . owner } ;
346
364
this . panelCollapsed . emit ( evArgs ) ;
347
365
} ) ;
0 commit comments