Skip to content

Commit b64bf3c

Browse files
committed
fix(tabs): Leak from undestroyed animations
1 parent 2e1466f commit b64bf3c

File tree

5 files changed

+11
-3
lines changed

5 files changed

+11
-3
lines changed

projects/igniteui-angular/src/lib/carousel/carousel-base.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ export abstract class IgxCarouselComponentBase {
8181
protected cdr: ChangeDetectorRef) {
8282
}
8383

84+
public baseDestroy(): void {
85+
this.enterAnimationPlayer?.destroy();
86+
this.leaveAnimationPlayer?.destroy();
87+
}
88+
8489
/** @hidden */
8590
protected triggerAnimations() {
8691
if (this.animationType !== CarouselAnimationType.none) {
@@ -177,7 +182,7 @@ export abstract class IgxCarouselComponentBase {
177182
this.enterAnimationPlayer.animationEnd.subscribe(() => {
178183
// TODO: animation may never end. Find better way to clean up the player
179184
if (this.enterAnimationPlayer) {
180-
this.enterAnimationPlayer.reset();
185+
this.enterAnimationPlayer.destroy();
181186
this.enterAnimationPlayer = null;
182187
}
183188
this.animationPosition = 0;
@@ -200,7 +205,7 @@ export abstract class IgxCarouselComponentBase {
200205
this.leaveAnimationPlayer.animationEnd.subscribe(() => {
201206
// TODO: animation may never end. Find better way to clean up the player
202207
if (this.leaveAnimationPlayer) {
203-
this.leaveAnimationPlayer.reset();
208+
this.leaveAnimationPlayer.destroy();
204209
this.leaveAnimationPlayer = null;
205210
}
206211
this.animationPosition = 0;

projects/igniteui-angular/src/lib/carousel/carousel.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,7 @@ export class IgxCarouselComponent extends IgxCarouselComponentBase implements IC
754754

755755
/** @hidden */
756756
public ngOnDestroy() {
757+
super.baseDestroy();
757758
this.destroy$.next(true);
758759
this.destroy$.complete();
759760
this.destroyed = true;

projects/igniteui-angular/src/lib/stepper/stepper.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ export class IgxStepperComponent extends IgxCarouselComponentBase implements Igx
386386

387387
/** @hidden @internal */
388388
public ngOnDestroy(): void {
389+
super.baseDestroy();
389390
this.destroy$.next();
390391
this.destroy$.complete();
391392
}

projects/igniteui-angular/src/lib/tabs/tabs.directive.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ export abstract class IgxTabsDirective extends IgxCarouselComponentBase implemen
150150

151151
/** @hidden */
152152
public ngOnDestroy(): void {
153+
super.baseDestroy();
153154
if (this._itemChanges$) {
154155
this._itemChanges$.unsubscribe();
155156
}

projects/igniteui-angular/src/lib/tabs/tabs/tabs.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const KEY_ENTER_EVENT = new KeyboardEvent('keydown', { key: 'Enter', bubbles: tr
2929
const KEY_SPACE_EVENT = new KeyboardEvent('keydown', { key: ' ', bubbles: true });
3030

3131
describe('IgxTabs', () => {
32-
configureTestSuite();
32+
configureTestSuite({ checkLeaks: true });
3333

3434
const tabItemNormalCssClass = 'igx-tabs__header-item';
3535
const tabItemSelectedCssClass = 'igx-tabs__header-item--selected';

0 commit comments

Comments
 (0)