diff --git a/src/material/tabs/tab-body.ts b/src/material/tabs/tab-body.ts index 52f9734dce64..e1cf5ba8d685 100644 --- a/src/material/tabs/tab-body.ts +++ b/src/material/tabs/tab-body.ts @@ -251,7 +251,8 @@ export abstract class _MatTabBodyBase implements OnInit, OnDestroy { templateUrl: 'tab-body.html', styleUrls: ['tab-body.css'], encapsulation: ViewEncapsulation.None, - changeDetection: ChangeDetectionStrategy.OnPush, + // tslint:disable-next-line:validate-decorators + changeDetection: ChangeDetectionStrategy.Default, animations: [matTabsAnimations.translateTab], host: { 'class': 'mat-tab-body', diff --git a/src/material/tabs/tab-group.ts b/src/material/tabs/tab-group.ts index 72ca3d972df1..e7c103f1f667 100644 --- a/src/material/tabs/tab-group.ts +++ b/src/material/tabs/tab-group.ts @@ -360,7 +360,8 @@ export abstract class _MatTabGroupBase extends _MatTabGroupMixinBase implements templateUrl: 'tab-group.html', styleUrls: ['tab-group.css'], encapsulation: ViewEncapsulation.None, - changeDetection: ChangeDetectionStrategy.OnPush, + // tslint:disable-next-line:validate-decorators + changeDetection: ChangeDetectionStrategy.Default, inputs: ['color', 'disableRipple'], host: { 'class': 'mat-tab-group', diff --git a/src/material/tabs/tab-header.ts b/src/material/tabs/tab-header.ts index 464913d1eab3..61c3c5601c5b 100644 --- a/src/material/tabs/tab-header.ts +++ b/src/material/tabs/tab-header.ts @@ -83,7 +83,8 @@ export abstract class _MatTabHeaderBase extends MatPaginatedTabHeader implements inputs: ['selectedIndex'], outputs: ['selectFocusedIndex', 'indexFocused'], encapsulation: ViewEncapsulation.None, - changeDetection: ChangeDetectionStrategy.OnPush, + // tslint:disable-next-line:validate-decorators + changeDetection: ChangeDetectionStrategy.Default, host: { 'class': 'mat-tab-header', '[class.mat-tab-header-pagination-controls-enabled]': '_showPaginationControls', diff --git a/src/material/tabs/tab-nav-bar/tab-nav-bar.ts b/src/material/tabs/tab-nav-bar/tab-nav-bar.ts index fe64f3b02a50..4780f6f24f63 100644 --- a/src/material/tabs/tab-nav-bar/tab-nav-bar.ts +++ b/src/material/tabs/tab-nav-bar/tab-nav-bar.ts @@ -160,7 +160,8 @@ export abstract class _MatTabNavBase extends MatPaginatedTabHeader implements Af '[class.mat-warn]': 'color === "warn"', }, encapsulation: ViewEncapsulation.None, - changeDetection: ChangeDetectionStrategy.OnPush, + // tslint:disable-next-line:validate-decorators + changeDetection: ChangeDetectionStrategy.Default, }) export class MatTabNav extends _MatTabNavBase { @ContentChildren(forwardRef(() => MatTabLink), {descendants: true}) _items: QueryList; diff --git a/src/material/tabs/tab.ts b/src/material/tabs/tab.ts index 3f84dfff04c5..066fe921c995 100644 --- a/src/material/tabs/tab.ts +++ b/src/material/tabs/tab.ts @@ -38,13 +38,25 @@ const _MatTabMixinBase: CanDisableCtor & typeof MatTabBase = selector: 'mat-tab', templateUrl: 'tab.html', inputs: ['disabled'], - changeDetection: ChangeDetectionStrategy.OnPush, + // tslint:disable-next-line:validate-decorators + changeDetection: ChangeDetectionStrategy.Default, encapsulation: ViewEncapsulation.None, exportAs: 'matTab', }) export class MatTab extends _MatTabMixinBase implements OnInit, CanDisable, OnChanges, OnDestroy { /** Content for the tab label given by ``. */ - @ContentChild(MatTabLabel, {static: false}) templateLabel: MatTabLabel; + @ContentChild(MatTabLabel, {static: false}) + get templateLabel(): MatTabLabel { return this._templateLabel; } + set templateLabel(value: MatTabLabel) { + // Only update the templateLabel via query if there is actually + // a MatTabLabel found. This works around an issue where a user may have + // manually set `templateLabel` during creation mode, which would then get clobbered + // by `undefined` when this query resolves. + if (value) { + this._templateLabel = value; + } + } + private _templateLabel: MatTabLabel; /** * Template provided in the tab content that will be used if present, used to enable lazy-loading