Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(expansion): fix expansion .mat-expansion-panel-header styles #20019

Merged
merged 1 commit into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
padding-bottom: 20px;
}

.example-headers-align .mat-expansion-panel-header-title,
.example-headers-align .mat-expansion-panel-header-description {
flex-basis: 0;
}

.example-headers-align .mat-expansion-panel-header-description {
justify-content: space-between;
align-items: center;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
.example-headers-align .mat-expansion-panel-header-title,
.example-headers-align .mat-expansion-panel-header-description {
flex-basis: 0;
}

.example-headers-align .mat-expansion-panel-header-description {
justify-content: space-between;
align-items: center;
Expand Down
2 changes: 1 addition & 1 deletion src/material/expansion/expansion-panel-header.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<span class="mat-content">
<span class="mat-content" [class.mat-content-hide-toggle]="!_showToggle()">
<ng-content select="mat-panel-title"></ng-content>
<ng-content select="mat-panel-description"></ng-content>
<ng-content></ng-content>
Expand Down
21 changes: 21 additions & 0 deletions src/material/expansion/expansion-panel-header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,33 @@
flex: 1;
flex-direction: row;
overflow: hidden;

// width of .mat-expansion-indicator::after element
&.mat-content-hide-toggle {
margin-right: 8px;

[dir='rtl'] & {
margin-right: 0;
margin-left: 8px;
}

.mat-expansion-toggle-indicator-before & {
margin-left: 24px;
margin-right: 0;

[dir='rtl'] & {
margin-right: 24px;
margin-left: 0;
}
}
}
}

.mat-expansion-panel-header-title,
.mat-expansion-panel-header-description {
display: flex;
flex-grow: 1;
flex-basis: 0;
margin-right: 16px;
align-items: center;

Expand Down
13 changes: 7 additions & 6 deletions src/material/expansion/expansion.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ describe('MatExpansionPanel', () => {

it('should be able to render panel content lazily', fakeAsync(() => {
const fixture = TestBed.createComponent(LazyPanelWithContent);
const content = fixture.debugElement.query(
By.css('.mat-expansion-panel-content'),
)!.nativeElement;
const content = fixture.debugElement.query(By.css('.mat-expansion-panel-content'))!
.nativeElement;
fixture.detectChanges();

expect(content.textContent.trim())
Expand All @@ -82,9 +81,8 @@ describe('MatExpansionPanel', () => {

it('should render the content for a lazy-loaded panel that is opened on init', fakeAsync(() => {
const fixture = TestBed.createComponent(LazyPanelOpenOnLoad);
const content = fixture.debugElement.query(
By.css('.mat-expansion-panel-content'),
)!.nativeElement;
const content = fixture.debugElement.query(By.css('.mat-expansion-panel-content'))!
.nativeElement;
fixture.detectChanges();

expect(content.textContent.trim())
Expand Down Expand Up @@ -314,19 +312,22 @@ describe('MatExpansionPanel', () => {
it('should be able to hide the toggle', () => {
const fixture = TestBed.createComponent(PanelWithContent);
const header = fixture.debugElement.query(By.css('.mat-expansion-panel-header'))!.nativeElement;
const content = fixture.debugElement.query(By.css('.mat-content'))!.nativeElement;

fixture.detectChanges();

expect(header.querySelector('.mat-expansion-indicator'))
.withContext('Expected indicator to be shown.')
.toBeTruthy();
expect(content.classList).not.toContain('mat-content-hide-toggle');

fixture.componentInstance.hideToggle = true;
fixture.detectChanges();

expect(header.querySelector('.mat-expansion-indicator'))
.withContext('Expected indicator to be hidden.')
.toBeFalsy();
expect(content.classList).toContain('mat-content-hide-toggle');
});

it('should update the indicator rotation when the expanded state is toggled programmatically', fakeAsync(() => {
Expand Down