Skip to content

Commit b5c5bf4

Browse files
committed
fix(material/tabs): remove visibility style when hydrating
Before this commit, when using pre-rendering, the styling animation would only remove the `transform` style when hydrating the component. This commit fixes this by including `visibility` as styles to remove when playing the animations.
1 parent 35f07c5 commit b5c5bf4

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {LEFT_ARROW, RIGHT_ARROW} from '@angular/cdk/keycodes';
22
import {dispatchFakeEvent, dispatchKeyboardEvent} from '@angular/cdk/testing/private';
3+
import {CommonModule} from '@angular/common';
34
import {
45
Component,
56
DebugElement,
@@ -11,15 +12,14 @@ import {
1112
} from '@angular/core';
1213
import {
1314
ComponentFixture,
15+
TestBed,
1416
fakeAsync,
1517
flush,
16-
TestBed,
1718
tick,
1819
waitForAsync,
1920
} from '@angular/core/testing';
2021
import {By} from '@angular/platform-browser';
2122
import {BrowserAnimationsModule, NoopAnimationsModule} from '@angular/platform-browser/animations';
22-
import {CommonModule} from '@angular/common';
2323
import {Observable} from 'rxjs';
2424
import {
2525
MAT_TABS_CONFIG,
@@ -772,7 +772,7 @@ describe('MDC-based MatTabGroup', () => {
772772
);
773773

774774
expect(contentElements.map(element => element.style.visibility)).toEqual([
775-
'',
775+
'visible',
776776
'hidden',
777777
'hidden',
778778
'hidden',
@@ -785,7 +785,7 @@ describe('MDC-based MatTabGroup', () => {
785785
expect(contentElements.map(element => element.style.visibility)).toEqual([
786786
'hidden',
787787
'hidden',
788-
'',
788+
'visible',
789789
'hidden',
790790
]);
791791

@@ -795,7 +795,7 @@ describe('MDC-based MatTabGroup', () => {
795795

796796
expect(contentElements.map(element => element.style.visibility)).toEqual([
797797
'hidden',
798-
'',
798+
'visible',
799799
'hidden',
800800
'hidden',
801801
]);

src/material/tabs/tabs-animations.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88
import {
9+
AnimationTriggerMetadata,
910
animate,
1011
state,
1112
style,
1213
transition,
1314
trigger,
14-
AnimationTriggerMetadata,
1515
} from '@angular/animations';
1616

1717
/**
@@ -24,7 +24,10 @@ export const matTabsAnimations: {
2424
/** Animation translates a tab along the X axis. */
2525
translateTab: trigger('translateTab', [
2626
// Transitions to `none` instead of 0, because some browsers might blur the content.
27-
state('center, void, left-origin-center, right-origin-center', style({transform: 'none'})),
27+
state(
28+
'center, void, left-origin-center, right-origin-center',
29+
style({transform: 'none', visibility: 'visible'}),
30+
),
2831

2932
// If the tab is either on the left or right, we additionally add a `min-height` of 1px
3033
// in order to ensure that the element has a height before its state changes. This is

0 commit comments

Comments
 (0)