Feature Request
option to choose between fixed height or auto-height to fit md-option's
contents.
md-option's
height is fixed to 48px
its very helpful and descriptive to have an additional text (maybe in smaller font-size) to show more information in the options, rather than having one line of text which only show one information.
Angular material 2.0.0-beta.3
Possible duplicate of #3883
Potentially doable for autocomplete, would be much more difficult for select.
@jelbourn yes it will be great to have it for autocomplete, I believe many Web Apps will rely heavily on autocomplete to select and filter hundreds of options (and I don't think md-select
is the right component for that -- since it has no textbox to type and find options)
@gedclack you are only saying that under the assumption that md-select can not do that, which it certainly can and there is pending (for two months) PR for it already https://github.com/angular/material2/pull/3211
In fact, I think autocomplete is definitely NOT the right component for selecting, that's what select is for, as autocomplete doesn't by default (and currently not even with option) enforce the selection to be the one of the list, it simply does the completion.
Also @jelbourn it will only be more difficult if you do that the actual "autoheight", if you allow the user to set the default (fixed) height, instead of hardcoding it, or do something like md-line on md-list, it shouldn't be difficult at all.
and
Based on the material design spec, we don't see multi-line options for
being permitted
I don't see it being prohibited either, but if it is the case, allowing the user to set the fixed height of all items should still be considered.
@fxck well it will be great then :+1: , I am just assuming with the current version of Material2.
@jelbourn IMHO (and with current version of Material2), if you add this #3334 that will be the solution for #3211
I believe having the possibility to use ng-template
instead of md-option
in options list for md-autocomplete
would be nice. Please?
@jelbourn is this resolved in the recent updates?
*haven't touch angular projects for a few weeks now..
@jelbourn is there an ETA for providing multiline support for autocomplete suggestion panel?
I'm using this workaround and it works fine for now:
mat-list.<<my-list-class>> ::ng-deep .mat-list-item-content {
height: <<new height>>;
}
That's not gonna work. The height is internally hardwired so they can calculate position of the active item upon opening. Overriding the height just in css is going to mess it up.
@fxck it worked well enough for my use case. That being said, it's definitely not a solution and this issue should be open.
In any case, a have another workaround that should play nicer with other css rules:
<mat-list-item *ngFor="<<let something of somethings>>">
<div style="height: <<my-height>>; width: 100%;">
<span matLine></span><span matLine></span><span matLine></span><span matLine></span>
<<my-line-content>>
</div>
</mat-list-item>
(material applies 'mat-multi-line' class when there are more than 3 matLine) (IMHO we probably need something like MatFitContent directive on mat-list-item that does the same)
Also apparently you are talking about mat-list, while this issue is about mat-autocomplete and mat-select.
@fxck ohh... you're right, sorry, I thought I was writing in https://github.com/angular/material2/issues/4114 (which should be re-opened IMO)
Any updates on this function?
This takes care of my needs for displaying multiple lines of content in a single mat-option.
<mat-option *ngFor="let emp of empDataSource | async" style="height: 90px;" [value]="emp">
{{emp.searchDisplay}}
<br> Building: {{emp.thing1}}
<br> Room: {{emp.thing2}}
</mat-option>
Could someone provide an update on this? What would the proper syntax for using mat-option
if
displayed value is too long?
Adding this style to mat-option
appears to solve the problem for us:
style="min-height: 48px; line-height: normal; height: auto; padding: 10px 20px;"
So final component should like something like:
<mat-form-field class="w-100">
<input matInput placeholder="Role" aria-label="Role" [matAutocomplete]="auto" [formControl]="roleCtrl">
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let Role of Roles | async" [value]="Role.name" style="min-height: 48px; line-height: normal; height: auto; padding: 10px 20px;">
<span>{{Role.name}}</span><br />
<small class="text-grey">{{Role.description}}</small>
</mat-option>
</mat-autocomplete>
</mat-form-field>
I'm using @martin-dmtrv solution but with these styles:
min-height: 48px; line-height: 1.15; height: auto; padding: 8px 16px; white-space: normal;
Which more following base Material styles.
Any updates?
for now I'm using similar workaround, adding this css below and using it on my AutoComplete's <mat-option>
.multiline-auto-complete-options {
height: auto !important;
line-height: normal !important;
padding: 8px 16px !important;
}
Most helpful comment
Any updates on this function?