Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular material 2 autocomplete position wrong

I have a problem with autocomplete of material 2.

In my case, I populate the list when the user write down something in the input, but the div(panel) with the options always appear bellow (If the screen is small I have to scroll down the page). It should appear above the input field when screen is small.

I think the problem is that the position of the panel is only initialised at the beginning when the input is clicked. Anyone can help me with any solution? Is there a way to reset positionY when the list is updated?

Thanks

like image 982
Neich Avatar asked Jul 24 '17 09:07

Neich


2 Answers

For me the problem was core css classes missing from the project.

[Fix] in style.css, at top level, add:

@import '~@angular/material/prebuilt-themes/deeppurple-amber.css';
like image 145
Bogdan M. Avatar answered Oct 02 '22 10:10

Bogdan M.


Try to add this to your style.css

.cdk-overlay-container{position:fixed;z-index:1000}
.cdk-global-overlay-wrapper{display:flex;position:absolute;z-index:1000}
.cdk-overlay-pane{position:absolute;pointer-events:auto;box-sizing:border-
 box;z-index:1000}
like image 20
FierceDev Avatar answered Oct 02 '22 09:10

FierceDev