Material: md-autocomplete should allow custom result height

Created on 13 Oct 2015  路  19Comments  路  Source: angular/material

Currently I can't find a way to target a specific md-autocomplete-suggestions-container/md-virtual-repeat-container in order to set a custom height for the result list.

md-autocomplete should set the md-menu-class or something else on the container so it can be targeted by CSS rules.

Most helpful comment

But this will be applicable for all the autocomplete inside the application. Can we write some kind of wrapper class on top of this

e.g.
.custom-app-wrapper .md-virtual-repeat-container.md-autocomplete-suggestions-container {
position: fixed;
bottom: 50px !important;
height: initial !important;
max-height: 99999999px !important;
}

I tried it but somehow the generated List is not generated inside the same element, it is a virtual list somewhere at bottom of DOM tree.

Can anybody suggest any way to achieve this ?

All 19 comments

Maybe it would be better to add support for md-auto-shrink & md-auto-shrink-min parameters directly on md-autocomplete directive. I will check how md-autocomplete communicates with md-virtual-repeat-container and will try to submit a PR for this.

FYI, you are correct, I couldn't find a way to set height.... but for reference, this ticket is how you can set WIDTH

https://github.com/angular/material/issues/4772

Exactly what I'm looking for. The hardcoded height limit to only show up-to 5 items is really limiting. Any update on potential release date or a work-around?

+1

+1

+1

+1

+1

As a workaround I am able to resize the suggestion box by overriding the CSS:

.md-virtual-repeat-container.md-autocomplete-suggestions-container {
    height: 420px;
    max-height: 420px !important;
}

@muhengseow Yes, but that only works if you have just one of those.

+1

+1

This makes the solution from @muhengseow slightly more generic, if you want a 'full height' solution.

.md-virtual-repeat-container.md-autocomplete-suggestions-container {
    position: fixed;
    bottom: 50px !important;
    height: initial !important;
    max-height: 99999999px !important;
}

But this will be applicable for all the autocomplete inside the application. Can we write some kind of wrapper class on top of this

e.g.
.custom-app-wrapper .md-virtual-repeat-container.md-autocomplete-suggestions-container {
position: fixed;
bottom: 50px !important;
height: initial !important;
max-height: 99999999px !important;
}

I tried it but somehow the generated List is not generated inside the same element, it is a virtual list somewhere at bottom of DOM tree.

Can anybody suggest any way to achieve this ?

+1

+1

+1

I was using Gimmeaphatbeat solution, but found that the drop down no longer displayed if there wasn't enough space at the bottom for the full height.

I would also like a solution like maheshk172's

ADD md-dropdown-items
The default is 5.
md-dropdown-items = "7"

Was this page helpful?
0 / 5 - 0 ratings

Related issues

buzybee83 picture buzybee83  路  3Comments

bobber205 picture bobber205  路  3Comments

epelc picture epelc  路  3Comments

ghost picture ghost  路  3Comments

PeerInfinity picture PeerInfinity  路  3Comments