-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Feature request for autocomplete - more control over panel width #4196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
A simple hack by controlling the width by using .mat-autocomplete-panel class .mat-autocomplete-panel { |
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. |
I also need this. |
I would set
|
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. import {Directive, DoCheck, ElementRef, Input} from '@angular/core';
import {MdAutocomplete} from '@angular/material';
@Directive({
selector: 'md-autocomplete[appAddClassToAutocomplete]',
providers: [MdAutocomplete]
})
export class AddClassToAutocompleteDirective implements DoCheck {
@Input() appAddClassToAutocomplete: string;
private panel: ElementRef;
constructor(private mdAutocomplete: MdAutocomplete) {}
ngDoCheck(): void {
const panel = this.mdAutocomplete.panel;
if (panel && !this.panel) {
this.panel = panel;
panel.nativeElement.parentElement.classList.add(this.appAddClassToAutocomplete);
}
}
} |
implemented simalar to select's panel class feature. fixes angular#4196.
implemented simalar to select's panel class feature. fixes angular#4196.
implemented simalar to select's panel class feature. fixes angular#4196.
Transfers any classes added to `md-autocomplete` to the resulting panel, allowing for easier styling similarly to `md-menu`. Fixes angular#4196.
Transfers any classes added to `md-autocomplete` to the resulting panel, allowing for easier styling similarly to `md-menu`. Fixes angular#4196.
Transfers any classes added to `md-autocomplete` to the resulting panel, allowing for easier styling similarly to `md-menu`. Fixes #4196.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug, feature request, or proposal:
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 are the steps to reproduce?
http://plnkr.co/edit/cKRWeypQ1UmpIk3s2c1E?p=preview
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?
The text was updated successfully, but these errors were encountered: