You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature request for autocomplete - more control over panel width #4196
Provide an option to control the width of the panel, perhaps via css:
<md-autocomplete #auto="mdAutocomplete" panel-class="my-autocomplete-css">
Or if it could just expand to fit the dropdown content that would be nice.
What is the expected behavior?
Allow the autocomplete dropdown panel to be a different width than the associated input field.
What is the current behavior?
The dropdown panel is the same width as the associated input field, which cuts off long values. There doesn't appear to be a way to change the width. A class or style on the md-autocomplete tag is ignored. Wrapping the options in a div with a wider style simply adds a scrollbar to the dropdown rather than widening it.
What is the use-case or motivation for changing an existing behavior?
Any situation where the dropdown options contain more information than what gets displayed in the text input. In my case, I'm using the dropdown as a list of search results. Each search result contains a name, an ID, a type, and several other fields to help the user select the appropriate result. But in the text box I just show the ID.
What I'd like is to make the dropdown wide enough to show all of the information in the search results, while the text input is narrower since it only shows the ID.
Which versions of Angular, Material, OS, browsers are affected?
Latest version, Chrome, Firefox, IE, Edge
Is there anything else we should know?
Reacted by David Reher, asequeir-public, Michael Prentice, Chris Marx, Vojtech Machacek and Miguel Malcolm
I also need this.
I need the panel width to be auto, to grow or shrink as the values inside. This way i can always see and doesn't get cut.
So, any news about this?
I would set min-width rather than width. As willshowell mentioned, your other option is to expand your MdInput/MdInputContainer width when it's focused, which expands the autocomplete width.
body .mat-autocomplete-panel {
min-width : 200px;
}
I also need this, as I need some panel to fit their content and some to fit input width, so the resolution above does not suit for me as it affects all autocomplete panels in project.
I came up with a small work around, but it works with a slight delay.
Activity
shaunak1111 commentedon May 11, 2017
A simple hack by controlling the width by using .mat-autocomplete-panel class
.mat-autocomplete-panel {
width : 200px;
}
willshowell commentedon May 11, 2017
Not sure if it would work for your use-case, but another option is to have the input expand upon focus. See the repro in #4146 for an example.
sadplace commentedon Jun 16, 2017
I also need this.
I need the panel width to be auto, to grow or shrink as the values inside. This way i can always see and doesn't get cut.
So, any news about this?
arlowhite commentedon Jun 26, 2017
I would set
min-widthrather thanwidth. As willshowell mentioned, your other option is to expand your MdInput/MdInputContainer width when it's focused, which expands the autocomplete width.ginvaell commentedon Aug 24, 2017
I also need this, as I need some panel to fit their content and some to fit input width, so the resolution above does not suit for me as it affects all autocomplete panels in project.
I came up with a small work around, but it works with a slight delay.
feat(autocomplete): add input for adding classes to the panel
feat(autocomplete): add input for adding classes to the panel
feat(autocomplete): add input for adding classes to the panel
feat(autocomplete): add md-autocomplete classes to overlay panel
feat(autocomplete): add md-autocomplete classes to overlay panel
feat(autocomplete): add md-autocomplete classes to overlay panel (#7176)
angular-automatic-lock-bot commentedon Sep 7, 2019
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.