Skip to content

Commit 38268d3

Browse files
amcdnlkara
authored andcommitted
fix(tabs): update tab output names (#7134)
1 parent 8d05772 commit 38268d3

File tree

5 files changed

+18
-11
lines changed

5 files changed

+18
-11
lines changed

src/lib/tabs/tab-body.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ export class MatTabBody implements OnInit, AfterViewChecked {
9191
@ViewChild(PortalHostDirective) _portalHost: PortalHostDirective;
9292

9393
/** Event emitted when the tab begins to animate towards the center as the active tab. */
94-
@Output() onCentering: EventEmitter<number> = new EventEmitter<number>();
94+
@Output() _onCentering: EventEmitter<number> = new EventEmitter<number>();
9595

9696
/** Event emitted when the tab completes its animation towards the center. */
97-
@Output() onCentered: EventEmitter<void> = new EventEmitter<void>(true);
97+
@Output() _onCentered: EventEmitter<void> = new EventEmitter<void>(true);
9898

9999
/** The tab body content to display. */
100100
@Input('content') _content: TemplatePortal<any>;
@@ -151,7 +151,7 @@ export class MatTabBody implements OnInit, AfterViewChecked {
151151

152152
_onTranslateTabStarted(e: AnimationEvent) {
153153
if (this._isCenterPosition(e.toState)) {
154-
this.onCentering.emit(this._elementRef.nativeElement.clientHeight);
154+
this._onCentering.emit(this._elementRef.nativeElement.clientHeight);
155155
}
156156
}
157157

@@ -163,7 +163,7 @@ export class MatTabBody implements OnInit, AfterViewChecked {
163163

164164
// If the transition to the center is complete, emit an event.
165165
if (this._isCenterPosition(e.toState) && this._isCenterPosition(this._position)) {
166-
this.onCentered.emit();
166+
this._onCentered.emit();
167167
}
168168
}
169169

src/lib/tabs/tab-group.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
[content]="tab.content"
3434
[position]="tab.position"
3535
[origin]="tab.origin"
36-
(onCentered)="_removeTabBodyWrapperHeight()"
37-
(onCentering)="_setTabBodyWrapperHeight($event)">
36+
(_onCentered)="_removeTabBodyWrapperHeight()"
37+
(_onCentering)="_setTabBodyWrapperHeight($event)">
3838
</mat-tab-body>
3939
</div>

src/lib/tabs/tab-group.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ describe('nested MatTabGroup with enabled animations', () => {
412412
[headerPosition]="headerPosition"
413413
[disableRipple]="disableRipple"
414414
(focusChange)="handleFocus($event)"
415-
(selectChange)="handleSelection($event)">
415+
(selectedTabChange)="handleSelection($event)">
416416
<mat-tab>
417417
<ng-template mat-tab-label>Tab One</ng-template>
418418
Tab one content
@@ -448,7 +448,7 @@ class SimpleTabsTestApp {
448448
<mat-tab-group class="tab-group"
449449
[(selectedIndex)]="selectedIndex"
450450
(focusChange)="handleFocus($event)"
451-
(selectChange)="handleSelection($event)">
451+
(selectedTabChange)="handleSelection($event)">
452452
<mat-tab *ngFor="let tab of tabs">
453453
<ng-template mat-tab-label>{{tab.label}}</ng-template>
454454
{{tab.content}}

src/lib/tabs/tab-group.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,15 @@ export class MatTabGroup extends _MatTabGroupMixinBase implements AfterContentIn
141141
@Output() focusChange: EventEmitter<MatTabChangeEvent> = new EventEmitter<MatTabChangeEvent>();
142142

143143
/** Event emitted when the tab selection has changed. */
144-
@Output() selectChange: EventEmitter<MatTabChangeEvent> =
144+
@Output() selectedTabChange: EventEmitter<MatTabChangeEvent> =
145145
new EventEmitter<MatTabChangeEvent>(true);
146146

147+
/**
148+
* Event emitted when the tab selection has changed.
149+
* @deprecated Use `selectedTabChange` instead.
150+
*/
151+
@Output() selectChange: EventEmitter<MatTabChangeEvent> = this.selectedTabChange;
152+
147153
private _groupId: number;
148154

149155
constructor(_renderer: Renderer2,
@@ -170,7 +176,8 @@ export class MatTabGroup extends _MatTabGroupMixinBase implements AfterContentIn
170176
// If there is a change in selected index, emit a change event. Should not trigger if
171177
// the selected index has not yet been initialized.
172178
if (this._selectedIndex != indexToSelect && this._selectedIndex != null) {
173-
this.selectChange.emit(this._createChangeEvent(indexToSelect));
179+
const tabChangeEvent = this._createChangeEvent(indexToSelect);
180+
this.selectedTabChange.emit(tabChangeEvent);
174181
// Emitting this value after change detection has run
175182
// since the checked content may contain this variable'
176183
Promise.resolve().then(() => this.selectedIndexChange.emit(indexToSelect));

src/lib/tabs/tabs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ tab labels in the header.
1010

1111
### Events
1212

13-
The `selectChange` output event is emitted when the active tab changes.
13+
The `selectedTabChange` output event is emitted when the active tab changes.
1414

1515
The `focusChange` output event is emitted when the user puts focus on any of the tab labels in
1616
the header, usually through keyboard navigation.

0 commit comments

Comments
 (0)