5
5
* Use of this source code is governed by an MIT-style license that can be
6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
+ import { FocusableOption , FocusMonitor } from '@angular/cdk/a11y' ;
8
9
import { Directionality } from '@angular/cdk/bidi' ;
10
+ import { BooleanInput , coerceBooleanProperty , NumberInput } from '@angular/cdk/coercion' ;
9
11
import { Platform } from '@angular/cdk/platform' ;
10
12
import { ViewportRuler } from '@angular/cdk/scrolling' ;
11
13
import {
12
14
AfterContentChecked ,
13
15
AfterContentInit ,
16
+ AfterViewInit ,
14
17
Attribute ,
15
18
ChangeDetectionStrategy ,
16
19
ChangeDetectorRef ,
@@ -27,7 +30,6 @@ import {
27
30
QueryList ,
28
31
ViewChild ,
29
32
ViewEncapsulation ,
30
- AfterViewInit ,
31
33
} from '@angular/core' ;
32
34
import {
33
35
CanDisable , CanDisableCtor ,
@@ -42,12 +44,10 @@ import {
42
44
RippleTarget ,
43
45
ThemePalette ,
44
46
} from '@angular/material/core' ;
45
- import { BooleanInput , coerceBooleanProperty , NumberInput } from '@angular/cdk/coercion' ;
46
- import { FocusMonitor , FocusableOption } from '@angular/cdk/a11y' ;
47
47
import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations' ;
48
+ import { startWith , takeUntil } from 'rxjs/operators' ;
48
49
import { MatInkBar } from '../ink-bar' ;
49
50
import { MatPaginatedTabHeader , MatPaginatedTabHeaderItem } from '../paginated-tab-header' ;
50
- import { startWith , takeUntil } from 'rxjs/operators' ;
51
51
52
52
/**
53
53
* Base class with all of the `MatTabNav` functionality.
@@ -201,7 +201,9 @@ export class _MatTabLinkBase extends _MatTabLinkMixinBase implements AfterViewIn
201
201
@Input ( )
202
202
get active ( ) : boolean { return this . _isActive ; }
203
203
set active ( value : boolean ) {
204
- if ( value !== this . _isActive ) {
204
+ const newValue = coerceBooleanProperty ( value ) ;
205
+
206
+ if ( newValue !== this . _isActive ) {
205
207
this . _isActive = value ;
206
208
this . _tabNavBar . updateActiveLink ( this . elementRef ) ;
207
209
}
@@ -225,7 +227,8 @@ export class _MatTabLinkBase extends _MatTabLinkMixinBase implements AfterViewIn
225
227
}
226
228
227
229
constructor (
228
- private _tabNavBar : _MatTabNavBase , public elementRef : ElementRef ,
230
+ private _tabNavBar : _MatTabNavBase ,
231
+ /** @docs -private */ public elementRef : ElementRef ,
229
232
@Optional ( ) @Inject ( MAT_RIPPLE_GLOBAL_OPTIONS ) globalRippleOptions : RippleGlobalOptions | null ,
230
233
@Attribute ( 'tabindex' ) tabIndex : string , private _focusMonitor : FocusMonitor ,
231
234
@Optional ( ) @Inject ( ANIMATION_MODULE_TYPE ) animationMode ?: string ) {
@@ -239,6 +242,7 @@ export class _MatTabLinkBase extends _MatTabLinkMixinBase implements AfterViewIn
239
242
}
240
243
}
241
244
245
+ /** Focuses the tab link. */
242
246
focus ( ) {
243
247
this . elementRef . nativeElement . focus ( ) ;
244
248
}
@@ -251,6 +255,7 @@ export class _MatTabLinkBase extends _MatTabLinkMixinBase implements AfterViewIn
251
255
this . _focusMonitor . stopMonitoring ( this . elementRef ) ;
252
256
}
253
257
258
+ static ngAcceptInputType_active : BooleanInput ;
254
259
static ngAcceptInputType_disabled : BooleanInput ;
255
260
static ngAcceptInputType_disableRipple : BooleanInput ;
256
261
static ngAcceptInputType_tabIndex : NumberInput ;
0 commit comments