Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

autocomplete: Wrong height is set for md-virtual-repeat-container #6668

Closed
aliai opened this issue Jan 13, 2016 · 12 comments
Closed

autocomplete: Wrong height is set for md-virtual-repeat-container #6668

aliai opened this issue Jan 13, 2016 · 12 comments
Assignees
Labels
P4: minor Minor issues. May not be fixed without community contributions. resolution: fixed
Milestone

Comments

@aliai
Copy link

aliai commented Jan 13, 2016

Hi,

When focusing on an autocomplete field, sometimes the rendered suggestion list is shrunk to show only one item, whereas there are more items on the list. This happens quite randomly, sometimes more often than this particular demo (gif):

autocomplete-bug

I tried to debug this, but led to no results unfortunately. Here is my findings (sorry if it doesn't help much):

Setting a new height is triggered at VirtualRepeatController.prototype.containerUpdated when virtualRepeatUpdate_ method is called. The problem, I think, arises when the items (referred to the list of suggestions) sent to this method is an empty array.

Moreover, when the items array is correct, through the chain calls, at VirtualRepeatContainerController.prototype.autoShrink_, setSize_ method is never called, which seem to solve the problem if it did.

@ThomasBurleson ThomasBurleson added the P4: minor Minor issues. May not be fixed without community contributions. label Jan 14, 2016
@manish2535
Copy link

You can reproduce this for certain if you were to scroll to get an option and then try to open the list again.

demo

@gbaj
Copy link
Contributor

gbaj commented Jan 15, 2016

This is the same issue I think-
http://codepen.io/anon/pen/LGzxyK

In the input box, hit backspace twice. You'll see the new height isn't recalculated properly.

image

@ThomasBurleson ThomasBurleson modified the milestone: Backlog Jan 15, 2016
@gbaj
Copy link
Contributor

gbaj commented Jan 15, 2016

As a workaround- adding this into your getSuggestions function seems to work

this.timeout_(function() {
  var outerContainer = document.querySelector('.md-autocomplete-suggestions-container');
  var innerContainer = document.querySelector('.md-virtual-repeat-sizer');
  outerContainer.style.height = innerContainer.style.height;
});

@DanaKaspi
Copy link

👍

1 similar comment
@mribichich
Copy link

+1

@jayeshanandani
Copy link
Contributor

This seems to be related to #5611

@FME-nstokoe
Copy link

It's still happening in 1.1.1

@Venthe
Copy link

Venthe commented Jan 11, 2017

+1

@pyroflies
Copy link

Still happening.. not sure why these features are "offered" in the documentation when their basic use case functionalities are broken..

@amusto-broadsoft
Copy link

amusto-broadsoft commented Oct 18, 2017

@gbaj Your suggestion worked perfectly for me.
In my case I retrieved the element containers via link and made them available via scope to my directives controller.
When my onBlur ran, I did an if check and if the suggestionContainer height was 0 I simply updated it to match the virtualRepeaterContainers height which always seemed to persist.

In my case, I identified and made available via scope in link as follows:

var suggestionsContainer = angular.element(element).find('.md-autocomplete-suggestions-container');
var virtualRepeaterContainer = angular.element(element).find('.md-virtual-repeat-sizer');

scope.suggestionsContainer = suggestionsContainer;
scope.virtualRepeaterContainer = virtualRepeaterContainer;

Then, in my directives controller during my onBlur event:

$timeout(function() {
    if ($scope.suggestionsContainer[0].style.height === '0px') {
        $scope.suggestionsContainer[0].style.height = '528px';
    }
}, 2000);

@OrganicCat
Copy link

This is still around, although I've noticed for my particular use case it was only triggering the wrong height when the list was temporarily empty, and "md-not-found" was used. When removing md-not-found I could no longer trigger a bad height. This is possibly related to being called from a remote service.

@Splaktar Splaktar modified the milestones: Deprecated, 1.1.0 Feb 11, 2018
@Splaktar Splaktar self-assigned this Feb 11, 2018
@Splaktar
Copy link
Contributor

This appears to be fixed in 1.1.0 and seems to still be working properly in 1.1.7. Here's an updated CodePen for 1.1.0.

If you are seeing a similar problem against 1.1.7, please open a new issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P4: minor Minor issues. May not be fixed without community contributions. resolution: fixed
Projects
None yet
Development

No branches or pull requests