mat-expansion-panel - styles get messed up if panel is a child of another element
- Dominant language
- TypeScript
- Stars
- 25k
- Forks
- 6.8k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 91
Description
#### Bug, feature request, or proposal:
The styles of panels will get messed up in the panels are placed in another element (ex: `div`)
Please see pseudo-code example below:
```html
...
...
```
#### What is the expected behavior?
Panels should be styled correctly
#### What is the current behavior?

#### What is the use-case or motivation for changing an existing behavior?
I was trying to implement draggable panels and my implementation has panels inside divs.
#### Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Material 7.0.0-beta.2
#### Is there anything else we should know?
To fix replace [lines 15-29 in expansion-panel.scss](https://github.com/angular/material2/blob/master/src/lib/expansion/expansion-panel.scss#L15-L29):
```scss
.mat-accordion & {
&:not(.mat-expanded), &:not(.mat-expansion-panel-spacing) {
border-radius: 0;
}
&:first-of-type {
border-top-right-radius: $border-radius;
border-top-left-radius: $border-radius;
}
&:last-of-type {
border-bottom-right-radius: $border-radius;
border-bottom-left-radius: $border-radius;
}
}
```
... with the following:
```scss
.mat-accordion & {
&:not(.mat-expanded), &:not(.mat-expansion-panel-spacing) {
border-radius: 0;
}
}
.mat-accordion > &:first-child,
.mat-accordion > &:first-child:not(.mat-expansion-panel) & {
border-top-right-radius: $border-radius;
border-top-left-radius: $border-radius;
}
.mat-accordion > &:last-child,
.mat-accordion > *:last-child:not(.mat-expansion-panel) & {
border-bottom-right-radius: $border-radius;
border-bottom-left-radius: $border-radius;
}
```
Contributor guide
Research direction
Start in src/lib/expansion/expansion-panel.scss at the referenced lines 15-29 and reproduce the nested mat-expansion-panel markup with div wrappers. Compare the reported selector replacement with the existing styles, then verify that the first and last panels retain correct border radii when panels are nested inside other elements.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100