This repository was archived by the owner on Sep 5, 2024. It is now read-only.
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
autocomplete: dropdown always uses max-height when md-not-found is used #11426
Open
Description
Bug, enhancement request, or proposal: Bug
CodePen and steps to reproduce the issue:
CodePen Demo which demonstrates the issue: pOJMKB
Detailed Reproduction Steps:
- Open this codepen
- Click on the autocomplete
- Type "F"
What is the expected behavior?
The dropdown should have height 48px
What is the current behavior?
The dropdown has height 240px (as if there were five results)
What is the use-case or motivation for changing an existing behavior?
The current behaviour is ugly and therefore bad UI/UX.
Which versions of AngularJS, Material, OS, and browsers are affected?
- AngularJS: 1.6.9
- AngularJS Material: 1.1.10
- OS: Tested in windows but probably has the same problem on all
- Browsers: Tested in Chrome but probably has the same problem on all
Is there anything else we should know? Stack Traces, Screenshots, etc.
As shown by the GIF I included above, after performing the following steps, the autocomplete gets the height correct:
- Open the same codepen I mentioned above
- Click on the autocomplete
- Type "F"
- Observe the problem
- Click outside
- Click on the autocomplete again
- Press backspace
- Type "F" - Now it gets it right. Interestingly though, it is possible to see a scrollbar flashing on the right with height 48px, which is still ugly but less ugly than the initial problem.
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.