Skip to content

Commit b07ae39

Browse files
committed
fix(tabs): no longer use OnPush
This resolves an issue with ivy where the template content would be checked out of sync with the tab view. See #15440 for additional context.
1 parent 8dffd8e commit b07ae39

File tree

4 files changed

+34
-30
lines changed

4 files changed

+34
-30
lines changed

src/material/tabs/tab-body.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,31 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9+
import {AnimationEvent} from '@angular/animations';
10+
import {Direction, Directionality} from '@angular/cdk/bidi';
11+
import {CdkPortalOutlet, PortalHostDirective, TemplatePortal} from '@angular/cdk/portal';
912
import {
10-
Component,
13+
ChangeDetectionStrategy,
1114
ChangeDetectorRef,
12-
Input,
13-
Inject,
14-
Output,
15+
Component,
16+
ComponentFactoryResolver,
17+
Directive,
18+
ElementRef,
1519
EventEmitter,
20+
forwardRef,
21+
Inject,
22+
Input,
1623
OnDestroy,
1724
OnInit,
18-
ElementRef,
19-
Directive,
2025
Optional,
21-
ViewEncapsulation,
22-
ChangeDetectionStrategy,
23-
ComponentFactoryResolver,
24-
ViewContainerRef,
25-
forwardRef,
26+
Output,
2627
ViewChild,
28+
ViewContainerRef,
29+
ViewEncapsulation,
2730
} from '@angular/core';
28-
import {AnimationEvent} from '@angular/animations';
29-
import {TemplatePortal, CdkPortalOutlet, PortalHostDirective} from '@angular/cdk/portal';
30-
import {Directionality, Direction} from '@angular/cdk/bidi';
31-
import {Subscription, Subject} from 'rxjs';
31+
import {Subject, Subscription} from 'rxjs';
32+
import {distinctUntilChanged, startWith} from 'rxjs/operators';
3233
import {matTabsAnimations} from './tabs-animations';
33-
import {startWith, distinctUntilChanged} from 'rxjs/operators';
3434

3535
/**
3636
* These position states are used internally as animation states for the tab body. Setting the
@@ -108,7 +108,8 @@ export class MatTabBodyPortal extends CdkPortalOutlet implements OnInit, OnDestr
108108
templateUrl: 'tab-body.html',
109109
styleUrls: ['tab-body.css'],
110110
encapsulation: ViewEncapsulation.None,
111-
changeDetection: ChangeDetectionStrategy.OnPush,
111+
// tslint:disable-next-line:validate-decorators
112+
changeDetection: ChangeDetectionStrategy.Default,
112113
animations: [matTabsAnimations.translateTab],
113114
host: {
114115
'class': 'mat-tab-body',

src/material/tabs/tab-group.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ import {
1616
ContentChildren,
1717
ElementRef,
1818
EventEmitter,
19+
Inject,
20+
InjectionToken,
1921
Input,
2022
OnDestroy,
23+
Optional,
2124
Output,
2225
QueryList,
2326
ViewChild,
2427
ViewEncapsulation,
25-
Optional,
26-
Inject,
27-
InjectionToken,
2828
} from '@angular/core';
2929
import {
3030
CanColor,
@@ -35,10 +35,10 @@ import {
3535
mixinDisableRipple,
3636
ThemePalette,
3737
} from '@angular/material/core';
38+
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';
3839
import {merge, Subscription} from 'rxjs';
3940
import {MatTab} from './tab';
4041
import {MatTabHeader} from './tab-header';
41-
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';
4242

4343

4444
/** Used to generate unique ID's for each tab component */
@@ -84,7 +84,8 @@ const _MatTabGroupMixinBase: CanColorCtor & CanDisableRippleCtor & typeof MatTab
8484
templateUrl: 'tab-group.html',
8585
styleUrls: ['tab-group.css'],
8686
encapsulation: ViewEncapsulation.None,
87-
changeDetection: ChangeDetectionStrategy.OnPush,
87+
// tslint:disable-next-line:validate-decorators
88+
changeDetection: ChangeDetectionStrategy.Default,
8889
inputs: ['color', 'disableRipple'],
8990
host: {
9091
'class': 'mat-tab-group',

src/material/tabs/tab-header.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,31 @@
77
*/
88

99
import {Directionality} from '@angular/cdk/bidi';
10+
import {coerceBooleanProperty} from '@angular/cdk/coercion';
11+
import {Platform} from '@angular/cdk/platform';
1012
import {ViewportRuler} from '@angular/cdk/scrolling';
1113
import {
1214
AfterContentChecked,
1315
AfterContentInit,
16+
AfterViewInit,
1417
ChangeDetectionStrategy,
1518
ChangeDetectorRef,
1619
Component,
1720
ContentChildren,
1821
ElementRef,
22+
Inject,
23+
Input,
1924
NgZone,
2025
OnDestroy,
2126
Optional,
2227
QueryList,
2328
ViewChild,
2429
ViewEncapsulation,
25-
AfterViewInit,
26-
Input,
27-
Inject,
2830
} from '@angular/core';
2931
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';
30-
import {coerceBooleanProperty} from '@angular/cdk/coercion';
3132
import {MatInkBar} from './ink-bar';
32-
import {MatTabLabelWrapper} from './tab-label-wrapper';
33-
import {Platform} from '@angular/cdk/platform';
3433
import {MatPaginatedTabHeader} from './paginated-tab-header';
34+
import {MatTabLabelWrapper} from './tab-label-wrapper';
3535

3636
/**
3737
* The header of the tab group which displays a list of all the tabs in the tab group. Includes
@@ -48,7 +48,8 @@ import {MatPaginatedTabHeader} from './paginated-tab-header';
4848
inputs: ['selectedIndex'],
4949
outputs: ['selectFocusedIndex', 'indexFocused'],
5050
encapsulation: ViewEncapsulation.None,
51-
changeDetection: ChangeDetectionStrategy.OnPush,
51+
// tslint:disable-next-line:validate-decorators
52+
changeDetection: ChangeDetectionStrategy.Default,
5253
host: {
5354
'class': 'mat-tab-header',
5455
'[class.mat-tab-header-pagination-controls-enabled]': '_showPaginationControls',

src/material/tabs/tab.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ const _MatTabMixinBase: CanDisableCtor & typeof MatTabBase =
3838
selector: 'mat-tab',
3939
templateUrl: 'tab.html',
4040
inputs: ['disabled'],
41-
changeDetection: ChangeDetectionStrategy.OnPush,
4241
encapsulation: ViewEncapsulation.None,
42+
// tslint:disable-next-line:validate-decorators
43+
changeDetection: ChangeDetectionStrategy.Default,
4344
exportAs: 'matTab',
4445
})
4546
export class MatTab extends _MatTabMixinBase implements OnInit, CanDisable, OnChanges, OnDestroy {

0 commit comments

Comments
 (0)