Skip to content

Commit 13ebccf

Browse files
authored
fix(tabs): change detection after animation - 13.0.x (#10707)
* fix(tabs): change detection after animation * fix(tabs): move change detection to tabs directive * fix(tabs): move change detection to carousel base
1 parent 5362121 commit 13ebccf

File tree

6 files changed

+18
-14
lines changed

6 files changed

+18
-14
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AnimationBuilder, AnimationPlayer, AnimationReferenceMetadata, useAnimation } from '@angular/animations';
2-
import { EventEmitter } from '@angular/core';
2+
import { ChangeDetectorRef, EventEmitter } from '@angular/core';
33
import { fadeIn } from '../animations/fade';
44
import { slideInLeft } from '../animations/slide';
55
import { mkenum } from '../core/utils';
@@ -49,7 +49,7 @@ export abstract class IgxCarouselComponentBase {
4949
/** @hidden */
5050
protected newDuration = 0;
5151

52-
constructor(private builder: AnimationBuilder) {
52+
constructor(private builder: AnimationBuilder, private cdr: ChangeDetectorRef) {
5353
}
5454

5555
/** @hidden */
@@ -86,6 +86,7 @@ export abstract class IgxCarouselComponentBase {
8686
if (this.animationStarted(this.enterAnimationPlayer)) {
8787
this.enterAnimationPlayer.reset();
8888
this.enterAnimationDone.emit();
89+
this.cdr.markForCheck();
8990
}
9091
}
9192

@@ -155,6 +156,7 @@ export abstract class IgxCarouselComponentBase {
155156
this.newDuration = 0;
156157
this.previousItem.previous = false;
157158
this.enterAnimationDone.emit();
159+
this.cdr.markForCheck();
158160
});
159161
this.previousItem.previous = true;
160162
this.enterAnimationPlayer.play();

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import {
1818
TemplateRef,
1919
ViewChild,
2020
ContentChild,
21-
Injectable
21+
Injectable,
22+
ChangeDetectorRef
2223
} from '@angular/core';
2324
import { IgxIconModule } from '../icon/public_api';
2425
import { IBaseEventArgs, mkenum, PlatformUtil } from '../core/utils';
@@ -534,9 +535,9 @@ export class IgxCarouselComponent extends IgxCarouselComponentBase implements On
534535
this.restartInterval();
535536
}
536537

537-
constructor(private element: ElementRef, private iterableDiffers: IterableDiffers,
538+
constructor(cdr: ChangeDetectorRef, private element: ElementRef, private iterableDiffers: IterableDiffers,
538539
builder: AnimationBuilder, private platformUtil: PlatformUtil) {
539-
super(builder);
540+
super(builder, cdr);
540541
this.differ = this.iterableDiffers.find([]).create(null);
541542
}
542543

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ describe('Stepper service unit tests', () => {
980980
};
981981

982982
stepperService = new IgxStepperService();
983-
stepper = new IgxStepperComponent(mockAnimationBuilder, stepperService, mockElementRef);
983+
stepper = new IgxStepperComponent(mockCdr, mockAnimationBuilder, stepperService, mockElementRef);
984984
steps = [];
985985
for (let index = 0; index < 4; index++) {
986986
const newStep = new IgxStepComponent(stepper, mockCdr, null,

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { CommonModule } from '@angular/common';
33
import {
44
Component, HostBinding, OnDestroy, OnInit,
55
Input, Output, EventEmitter, ContentChildren, QueryList, ElementRef,
6-
NgModule, OnChanges, SimpleChanges, TemplateRef, ContentChild, AfterContentInit
6+
NgModule, OnChanges, SimpleChanges, TemplateRef, ContentChild, AfterContentInit, ChangeDetectorRef
77
} from '@angular/core';
88
import { Subject } from 'rxjs';
99
import { takeUntil } from 'rxjs/operators';
@@ -331,10 +331,11 @@ export class IgxStepperComponent extends IgxCarouselComponentBase implements Igx
331331
private readonly _defaultAnimationDuration = 350;
332332

333333
constructor(
334+
cdr: ChangeDetectorRef,
334335
private animBuilder: AnimationBuilder,
335336
private stepperService: IgxStepperService,
336337
private element: ElementRef<HTMLElement>) {
337-
super(animBuilder);
338+
super(animBuilder, cdr);
338339
this.stepperService.stepper = this;
339340
}
340341

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { AnimationBuilder } from '@angular/animations';
22
import {
3-
AfterViewInit, ContentChildren, Directive, EventEmitter,
3+
AfterViewInit, ChangeDetectorRef, ContentChildren, Directive, EventEmitter,
44
Input, OnDestroy, Output, QueryList
55
} from '@angular/core';
66
import { Subscription } from 'rxjs';
@@ -119,8 +119,8 @@ export abstract class IgxTabsDirective extends IgxCarouselComponentBase implemen
119119
private _itemChanges$: Subscription;
120120

121121
/** @hidden */
122-
constructor(builder: AnimationBuilder) {
123-
super(builder);
122+
constructor(builder: AnimationBuilder, cdr: ChangeDetectorRef) {
123+
super(builder, cdr);
124124
}
125125

126126
/** @hidden */

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AnimationBuilder } from '@angular/animations';
2-
import { AfterViewInit, Component, ElementRef, HostBinding, Input, NgZone, OnDestroy, ViewChild } from '@angular/core';
2+
import { AfterViewInit, ChangeDetectorRef, Component, ElementRef, HostBinding, Input, NgZone, OnDestroy, ViewChild } from '@angular/core';
33
import { getResizeObserver, mkenum } from '../../core/utils';
44
import { IgxTabsBase } from '../tabs.base';
55
import { IgxTabsDirective } from '../tabs.directive';
@@ -118,8 +118,8 @@ export class IgxTabsComponent extends IgxTabsDirective implements AfterViewInit,
118118
private _tabAlignment: string | IgxTabsAlignment = 'start';
119119
private _resizeObserver: ResizeObserver;
120120

121-
constructor(builder: AnimationBuilder, private ngZone: NgZone) {
122-
super(builder);
121+
constructor(builder: AnimationBuilder, cdr: ChangeDetectorRef, private ngZone: NgZone) {
122+
super(builder, cdr);
123123
}
124124

125125

0 commit comments

Comments
 (0)