@@ -63,9 +63,7 @@ export abstract class _MatTabNavBase
63
63
implements AfterContentChecked , AfterContentInit , OnDestroy
64
64
{
65
65
/** Query list of all tab links of the tab navigation. */
66
- abstract override _items : QueryList <
67
- MatPaginatedTabHeaderItem & { active : boolean ; _uniqueId : string }
68
- > ;
66
+ abstract override _items : QueryList < MatPaginatedTabHeaderItem & { active : boolean ; id : string} > ;
69
67
70
68
/** Background color of the tab nav. */
71
69
@Input ( )
@@ -144,7 +142,7 @@ export abstract class _MatTabNavBase
144
142
this . _changeDetectorRef . markForCheck ( ) ;
145
143
146
144
if ( this . panel ) {
147
- this . panel . _activeTabId = items [ i ] . _uniqueId ;
145
+ this . panel . _activeTabId = items [ i ] . id ;
148
146
}
149
147
150
148
return ;
@@ -258,8 +256,8 @@ export class _MatTabLinkBase
258
256
) ;
259
257
}
260
258
261
- /** Unique id for the component referenced in ARIA attributes . */
262
- _uniqueId = `mat-tab-link-${ nextUniqueId ++ } ` ;
259
+ /** Unique id for the tab . */
260
+ @ Input ( ) id = `mat-tab-link-${ nextUniqueId ++ } ` ;
263
261
264
262
constructor (
265
263
private _tabNavBar : _MatTabNavBase ,
@@ -304,16 +302,17 @@ export class _MatTabLinkBase
304
302
}
305
303
}
306
304
307
- _getTabIndex ( ) {
305
+ /** Returns the tab's tabindex. */
306
+ _getTabIndex ( ) : number {
308
307
if ( ! this . _tabNavBar . panel ) {
309
308
return this . tabIndex ;
310
309
}
311
310
312
311
if ( ! this . _tabNavBar . _items ) {
313
- return this . _isActive ? '0' : '-1' ;
312
+ return this . _isActive ? 0 : - 1 ;
314
313
}
315
314
316
- return this . _tabNavBar . focusIndex === this . _getIndex ( ) ? '0' : '-1' ;
315
+ return this . _tabNavBar . focusIndex === this . _getIndex ( ) ? 0 : - 1 ;
317
316
}
318
317
319
318
/** Returns this item's index in the nav bar. */
@@ -336,11 +335,11 @@ export class _MatTabLinkBase
336
335
inputs : [ 'disabled' , 'disableRipple' , 'tabIndex' ] ,
337
336
host : {
338
337
'class' : 'mat-tab-link mat-focus-indicator' ,
339
- '[attr.aria-controls]' : '_tabNavBar.panel ? _tabNavBar.panel._uniqueId : null' ,
340
- '[attr.aria-current]' : 'active && !_tabNavBar.panel ? "page" : null' ,
338
+ '[attr.aria-controls]' : '_tabNavBar.panel ? _tabNavBar.panel.id : null' ,
339
+ '[attr.aria-current]' : '( active && !_tabNavBar.panel) ? "page" : null' ,
341
340
'[attr.aria-disabled]' : 'disabled' ,
342
341
'[attr.aria-selected]' : '_tabNavBar.panel ? (active ? "true" : "false") : null' ,
343
- '[attr.id]' : '_uniqueId ' ,
342
+ '[attr.id]' : 'id ' ,
344
343
'[attr.tabIndex]' : '_getTabIndex()' ,
345
344
'[attr.role]' : '_tabNavBar.panel ? "tab" : null' ,
346
345
'[class.mat-tab-disabled]' : 'disabled' ,
@@ -382,18 +381,18 @@ export class MatTabLink extends _MatTabLinkBase implements OnDestroy {
382
381
exportAs : 'matTabNavPanel' ,
383
382
template : '<ng-content select="router-outlet"></ng-content>' ,
384
383
host : {
385
- '[attr.aria-labelledby]' : '_activeTabId || null ' ,
386
- '[attr.id]' : '_uniqueId ' ,
384
+ '[attr.aria-labelledby]' : '_activeTabId' ,
385
+ '[attr.id]' : 'id ' ,
387
386
'role' : 'tabpanel' ,
388
387
} ,
389
388
encapsulation : ViewEncapsulation . None ,
390
389
// tslint:disable-next-line:validate-decorators
391
390
changeDetection : ChangeDetectionStrategy . Default ,
392
391
} )
393
392
export class MatTabNavPanel {
393
+ /** Unique id for the tab panel. */
394
+ @Input ( ) id = `mat-tab-nav-panel-${ nextUniqueId ++ } ` ;
395
+
394
396
/** Id of the active tab in the nav bar. */
395
397
_activeTabId ?: string ;
396
-
397
- /** Unique id for the component referenced in ARIA attributes. */
398
- _uniqueId = `mat-tab-nav-panel-${ nextUniqueId ++ } ` ;
399
398
}
0 commit comments