Skip to content

fix(tabs): no longer use OnPush #16529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/material/tabs/tab-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 2 additions & 1 deletion src/material/tabs/tab-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 2 additions & 1 deletion src/material/tabs/tab-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 2 additions & 1 deletion src/material/tabs/tab-nav-bar/tab-nav-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<MatTabLink>;
Expand Down
16 changes: 14 additions & 2 deletions src/material/tabs/tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<ng-template mat-tab-label>`. */
@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
Expand Down