Skip to content

Commit 0d0da2a

Browse files
committed
fix(material/tabs): allow coercing of booleans for all inputs
Previously, some properties were declared as BooleanInput and some not. With this commit, all boolean inputs are threat as BooleanInput and therefore the input value are being coerced.
1 parent 1c91731 commit 0d0da2a

File tree

4 files changed

+32
-7
lines changed

4 files changed

+32
-7
lines changed

src/components-examples/material/tabs/tab-group-preserve-content/tab-group-preserve-content-example.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<p>Start the video in the first tab and navigate to the second one to see how it keeps playing.</p>
22

3-
<mat-tab-group [preserveContent]="true">
3+
<mat-tab-group preserveContent>
44
<mat-tab label="First">
55
<iframe
66
width="560"

src/material/tabs/paginated-tab-header.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ import {
2222
Input,
2323
} from '@angular/core';
2424
import {Direction, Directionality} from '@angular/cdk/bidi';
25-
import {coerceNumberProperty, NumberInput} from '@angular/cdk/coercion';
25+
import {
26+
BooleanInput,
27+
coerceBooleanProperty,
28+
coerceNumberProperty,
29+
NumberInput,
30+
} from '@angular/cdk/coercion';
2631
import {ViewportRuler} from '@angular/cdk/scrolling';
2732
import {FocusKeyManager, FocusableOption} from '@angular/cdk/a11y';
2833
import {ENTER, SPACE, hasModifierKey} from '@angular/cdk/keycodes';
@@ -121,7 +126,13 @@ export abstract class MatPaginatedTabHeader
121126
* layout recalculations if it's known that pagination won't be required.
122127
*/
123128
@Input()
124-
disablePagination: boolean = false;
129+
get disablePagination(): boolean {
130+
return this._disablePagination;
131+
}
132+
set disablePagination(value: BooleanInput) {
133+
this._disablePagination = coerceBooleanProperty(value);
134+
}
135+
private _disablePagination: boolean = false;
125136

126137
/** The index of the active tab. */
127138
get selectedIndex(): number {

src/material/tabs/tab-group.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,27 @@ export abstract class _MatTabGroupBase
161161
* layout recalculations if it's known that pagination won't be required.
162162
*/
163163
@Input()
164-
disablePagination: boolean;
164+
get disablePagination(): boolean {
165+
return this._disablePagination;
166+
}
167+
set disablePagination(value: BooleanInput) {
168+
this._disablePagination = coerceBooleanProperty(value);
169+
}
170+
private _disablePagination: boolean;
165171

166172
/**
167173
* By default tabs remove their content from the DOM while it's off-screen.
168174
* Setting this to `true` will keep it in the DOM which will prevent elements
169175
* like iframes and videos from reloading next time it comes back into the view.
170176
*/
171177
@Input()
172-
preserveContent: boolean;
178+
get preserveContent(): boolean {
179+
return this._preserveContent;
180+
}
181+
set preserveContent(value: BooleanInput) {
182+
this._preserveContent = coerceBooleanProperty(value);
183+
}
184+
private _preserveContent: boolean;
173185

174186
/** Background color of the tab group. */
175187
@Input()

tools/public_api_guard/material/tabs.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ export abstract class _MatTabGroupBase extends _MatTabGroupMixinBase implements
233233
protected _changeDetectorRef: ChangeDetectorRef;
234234
get contentTabIndex(): number | null;
235235
set contentTabIndex(value: NumberInput);
236-
disablePagination: boolean;
236+
get disablePagination(): boolean;
237+
set disablePagination(value: BooleanInput);
237238
get dynamicHeight(): boolean;
238239
set dynamicHeight(value: BooleanInput);
239240
readonly focusChange: EventEmitter<MatTabChangeEvent>;
@@ -250,7 +251,8 @@ export abstract class _MatTabGroupBase extends _MatTabGroupMixinBase implements
250251
ngAfterContentInit(): void;
251252
// (undocumented)
252253
ngOnDestroy(): void;
253-
preserveContent: boolean;
254+
get preserveContent(): boolean;
255+
set preserveContent(value: BooleanInput);
254256
realignInkBar(): void;
255257
_removeTabBodyWrapperHeight(): void;
256258
get selectedIndex(): number | null;

0 commit comments

Comments
 (0)