Skip to content

Commit baec85e

Browse files
crisbetojelbourn
authored andcommitted
fix(material-experimental/mdc-tabs): error during server-side rendering (#17169)
Fixes an error that is thrown by the ink bar, because it tries to call `getBoundingClientRect` on the server. Also sets up the kitchen sink test for the MDC-based tabs.
1 parent f32fb68 commit baec85e

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/material-experimental/mdc-tabs/ink-bar.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ export class MatInkBarFoundation {
8282
this._indicatorContent.style.setProperty(propName, value);
8383
},
8484
computeContentClientRect: () => {
85-
return this._destroyed ? {
85+
// `getBoundingClientRect` isn't available on the server.
86+
return this._destroyed || !this._indicatorContent.getBoundingClientRect ? {
8687
width: 0, height: 0, top: 0, left: 0, right: 0, bottom: 0
8788
} : this._indicatorContent.getBoundingClientRect();
8889
}

src/universal-app/kitchen-sink-mdc/kitchen-sink-mdc.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,26 @@ <h2>Slider</h2>
5555
<mat-slider value="50"></mat-slider>
5656
<mat-slider tickInterval="1" min="1" max="10" value="5" thumbLabel></mat-slider>
5757
<mat-slider disabled></mat-slider>
58+
59+
<h2>Tabs</h2>
60+
61+
<!--
62+
Note that we set the `selectedIndex` here to hit the code path
63+
where we might need to do some measurements.
64+
-->
65+
<mat-tab-group [selectedIndex]="1">
66+
<mat-tab label="Overview">
67+
The overview
68+
</mat-tab>
69+
<mat-tab>
70+
<ng-template mat-tab-label>
71+
API docs
72+
</ng-template>
73+
The API docs
74+
</mat-tab>
75+
</mat-tab-group>
76+
77+
<nav mat-tab-nav-bar>
78+
<a mat-tab-link href="https://google.com">Google</a>
79+
<a mat-tab-link href="https://google.com" active>Also Google</a>
80+
</nav>

0 commit comments

Comments
 (0)