
The dropdown should have height 48px
The dropdown has height 240px (as if there were five results)
The current behaviour is ugly and therefore bad UI/UX.
As shown by the GIF I included above, after performing the following steps, the autocomplete gets the height correct:
Also, for those looking for a quick fix, I used an ugly hack: inside the getSearchValues() function I calculate the correct height (which is 48 * numberOfResults) and force the height of the container using javascript. See it working on this other codepen:
function fixBug(amountOfResults) {
function getLastElement(selector) {
const all = Array.prototype.slice.call(document.querySelectorAll(selector));
return all[all.length - 1];
}
setTimeout(() => {
const container = getLastElement("md-virtual-repeat-container");
const scroller = getLastElement("div.md-virtual-repeat-scroller");
const sizer = getLastElement("div.md-virtual-repeat-sizer");
const offsetter = getLastElement("div.md-virtual-repeat-offsetter");
const height = 48 * amountOfResults + "px";
container.style.height = height;
scroller.style.height = height;
sizer.style.height = height;
offsetter.style.height = height;
}, 0);
}
Note: I know I am using the autocomplete in a slightly unusual fashion (with the "type to search" thing and the "too many" thing) but I believe this constitutes a bug regardless.
I can reproduce this issue. It only happens with md-not-found. Currently this causes the dropdown panel to have max-height: 227px and height: 100%, but it does not set a min-height: 48px so the browser seems to always be using the max-height even when not needed.
In my brief testing, setting min-height: 48px on .md-virtual-repeat-container.md-autocomplete-suggestions-container and removing the height: 100% solves this. But this breaks the ability for the dropdown panel to expand when there is a full set of matches.
I wonder if using Flexbox could help us here...
Thanks for the quick reply. I'm afraid I can't help with fixing it, my CSS knowledge is not so deep. Good luck to you or whoever takes this :) Thanks for taking the time.
I noticed now that this is directly related to #6668