Bug
mat-list-item doesn't change size according to height of textarea
Height of
size of mat-list-item remains the same even though height of textarea is increased
Here is a link of StackBlitz:
https://stackblitz.com/edit/angular-gk9mvj
"@angular/animations": "^5.0.0-rc.0",
"@angular/cdk": "^5.0.0-rc.1",
"@angular/common": "^5.0.0-rc.0",
"@angular/compiler": "^5.0.0-rc.0",
"@angular/core": "^5.0.0-rc.0",
"@angular/flex-layout": "^2.0.0-beta.10-4905443",
"@angular/forms": "^5.0.0-rc.0",
"@angular/http": "^5.0.0-rc.0",
"@angular/material": "^5.0.0-rc.1",
"@angular/platform-browser": "^5.0.0-rc.0",
"@angular/platform-browser-dynamic": "^5.0.0-rc.0",
"@angular/platform-server": "^5.0.0-rc.0",
"@angular/router": "^5.0.0-rc.0",
AFAIK, this is the expected behavior: one low height row per list element. Try a gridlist (with 1 column) instead of a list.
I recently updated material and before the update it seemed to work just fine. I was previously using beta.6
If you take a look at the code you'll see the max height (its not constant, but it has some allowed values):
But shouldn't the height of the parent element change if it's children's height has changed?
You can override the default styles using yours with higher specificity:
.app-class .mat-list-item {
height: auto;
}
<mat-list class="app-class">
<mat-list-item>
<mat-form-field>
<textarea matInput rows="7"></textarea>
</mat-form-field>
</mat-list-item>
<mat-list-item>Item 2</mat-list-item>
<mat-list-item>Item 3</mat-list-item>
</mat-list>
Checkout over here: https://stackblitz.com/edit/angular-list-item-height
Yes i have solved it with providing css of higher specifity, but i believe height should be auto by default.
However i am closing this issue as this is not an issue but an expected behavior.
You can override the default styles using yours with higher specificity:
.app-class .mat-list-item { height: auto; }
I had a slightly different usecase where the textarea row height can change between 1 and 6 via cdkTextareaAutosize and I though I needed to do something complex like get a hook into that directive to trigger a change ... but simply overriding the default styles with higher specificity as you suggested, worked for me too 馃憤
https://stackblitz.com/edit/mat-list-height
Thank You @julianobrasil
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
You can override the default styles using yours with higher specificity:
Checkout over here: https://stackblitz.com/edit/angular-list-item-height