material icon indicating copy to clipboard operation
material copied to clipboard

Angular-material md-autocomplete append to body

Open lillylykho opened this issue 11 years ago • 9 comments

Hello everyone! I use awesome angular material feature md-autocomplete, but I have not found a property that I really need: append-to-body. Any ideas? Maybe it will be developed in the near future?

Thanks!

lillylykho avatar Mar 19 '15 07:03 lillylykho

Not sure if they have it but it might be a good to add a parent option much like mdDialog and mdToast.

epelc avatar Mar 19 '15 15:03 epelc

Can't you just put the directive next to the body? It isn't a service like mdDialog, which dynamically appends an interim element to the $rootElement or specified parent.

marcysutton avatar Mar 19 '15 23:03 marcysutton

@marcysutton Unfortunately it is so. Basically, I coped without it at the moment. But, really, it might be a good to add this option. Thanks.

lillylykho avatar Mar 23 '15 07:03 lillylykho

@marcysutton What if you have an autocomplete in a modal?

In this case you need the autocomplete suggestions UI to appear over the top (and to overflow outside of, the modal container, like a native select element would do). The suggestions popup should act like a native select in my opinion in that that UI that pops up should essentially be at the viewport level.

We have our own autocomplete directive in a real app which needed to be present in a modal and had the same problem. In my opinion the autocomplete should be using an interim element.

modal

The current implementation restricts it's use unfortunately.

WillsB3 avatar Mar 23 '15 08:03 WillsB3

@lillylykho @WillsB3 @marcysutton This is a valid point and one that I had planned to implement after the initial release. I was hoping to find a cleaner workaround, but it unfortunately seeming that I will have to update the dropdown portion of md-autocomplete to append to the body.

robertmesserle avatar Apr 02 '15 20:04 robertmesserle

@robertmesserle My concern is that there are several components which are going to have to same issue, e.g. Datepickers for one (and I'm positive there are/will be others (menus might be another example).

I was wondering if it might be beneficial to find a generic way to allow existing components to be rendered inside of some sort of "floating element" which could then be attached to the body? I'm not fully aware of the intricacies of how the $interimElement service works but know it's used in some components such as toasts, so perhaps $interimElement is suitable for this or perhaps not?

I've been working on a directive like this that acts as a sort of "portal" in that it allows components to be exist at the body level but be declared inline with the context of a controller/view so that the components still have access to the correct scope. However my implementation is pretty experimental and I'm sure there's a lot that could be improved. Do you or anyone else on the Angular Material team thing such a directive would be useful for the library in light of my concerns mentioned above?

WillsB3 avatar Apr 03 '15 11:04 WillsB3

@WillsB3 It would definitely be beneficial, and I will likely implement something like that as I continue work on md-autocomplete.

robertmesserle avatar Apr 03 '15 15:04 robertmesserle

Also notice this implementation of autoComplete in inbox.google.com:

screen shot 2015-04-03 at 11 55 46 am

The menu is below the toolbar.

ThomasBurleson avatar Apr 03 '15 16:04 ThomasBurleson

solution???

Avishaidev avatar Mar 23 '17 12:03 Avishaidev