Skip to content
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
papb opened this issue Aug 25, 2018 · 3 comments
Open

autocomplete: dropdown always uses max-height when md-not-found is used #11426

papb opened this issue Aug 25, 2018 · 3 comments
Labels
needs: investigation The cause of this issue is not well understood and needs to be investigated by the team or community P4: minor Minor issues. May not be fixed without community contributions. type: bug
Milestone

Comments

@papb
Copy link

papb commented Aug 25, 2018

Bug, enhancement request, or proposal: Bug

CodePen and steps to reproduce the issue:

CodePen Demo which demonstrates the issue: pOJMKB

Detailed Reproduction Steps:

GIF showing issue

  1. Open this codepen
  2. Click on the autocomplete
  3. 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:

  1. Open the same codepen I mentioned above
  2. Click on the autocomplete
  3. Type "F"
  4. Observe the problem
  5. Click outside
  6. Click on the autocomplete again
  7. Press backspace
  8. 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.

@papb papb changed the title autocomplete: dropdown height is completely wrong autocomplete: dropdown height is wrong Aug 25, 2018
@Splaktar Splaktar self-assigned this Aug 27, 2018
@Splaktar Splaktar changed the title autocomplete: dropdown height is wrong autocomplete: dropdown always uses max-height when md-not-found is used Aug 27, 2018
@Splaktar Splaktar added this to the 1.1.11 milestone Aug 27, 2018
@Splaktar Splaktar added type: bug needs: Pull Request P4: minor Minor issues. May not be fixed without community contributions. and removed good first issue labels Aug 27, 2018
@Splaktar
Copy link
Contributor

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...

@Splaktar Splaktar added needs: investigation The cause of this issue is not well understood and needs to be investigated by the team or community and removed needs: Pull Request labels Aug 27, 2018
@papb
Copy link
Author

papb commented Aug 28, 2018

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.

@Splaktar Splaktar modified the milestones: 1.1.11, 1.1.12 Sep 10, 2018
@papb
Copy link
Author

papb commented Oct 2, 2018

I noticed now that this is directly related to #6668

@Splaktar Splaktar modified the milestones: 1.1.12, 1.1.13 Jan 3, 2019
@Splaktar Splaktar modified the milestones: 1.1.13, 1.1.14 Feb 10, 2019
@Splaktar Splaktar removed their assignment Feb 23, 2019
@Splaktar Splaktar modified the milestones: 1.1.14, - Backlog Feb 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: investigation The cause of this issue is not well understood and needs to be investigated by the team or community P4: minor Minor issues. May not be fixed without community contributions. type: bug
Projects
None yet
Development

No branches or pull requests

2 participants