Skip to content

Commit

Permalink
fix(material/tabs): disablePagination not working (#26647)
Browse files Browse the repository at this point in the history
The tab group wasn't passing the `disablePagination` input to the tab header so it wasn't being picked up.

Fixes #26621.

(cherry picked from commit 3c53deb)
  • Loading branch information
crisbeto committed Feb 18, 2023
1 parent aa0c052 commit 277f65a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/material/tabs/tab-group.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<mat-tab-header #tabHeader
[selectedIndex]="selectedIndex || 0"
[disableRipple]="disableRipple"
[disablePagination]="disablePagination"
(indexFocused)="_focusChanged($event)"
(selectFocusedIndex)="selectedIndex = $event">

Expand Down
21 changes: 20 additions & 1 deletion src/material/tabs/tab-group.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,23 @@ describe('MDC-based MatTabGroup', () => {
jasmine.objectContaining({index: 1}),
);
}));

it('should be able to disable the pagination', fakeAsync(() => {
fixture.componentInstance.disablePagination = true;
fixture.detectChanges();
tick();

for (let i = 0; i < 50; i++) {
fixture.componentInstance.tabs.push({label: `Extra ${i}`, content: ''});
}

fixture.detectChanges();
tick();

expect(
fixture.nativeElement.querySelector('.mat-mdc-tab-header-pagination-controls-enabled'),
).toBeFalsy();
}));
});

describe('async tabs', () => {
Expand Down Expand Up @@ -1111,7 +1128,8 @@ class SimpleTabsTestApp {
<mat-tab-group class="tab-group"
[(selectedIndex)]="selectedIndex"
(focusChange)="handleFocus($event)"
(selectedTabChange)="handleSelection($event)">
(selectedTabChange)="handleSelection($event)"
[disablePagination]="disablePagination">
<mat-tab *ngFor="let tab of tabs">
<ng-template mat-tab-label>{{tab.label}}</ng-template>
{{tab.content}}
Expand All @@ -1128,6 +1146,7 @@ class SimpleDynamicTabsTestApp {
selectedIndex: number = 1;
focusEvent: any;
selectEvent: any;
disablePagination = false;
handleFocus(event: any) {
this.focusEvent = event;
}
Expand Down

0 comments on commit 277f65a

Please sign in to comment.