Material: select(multiple): label doesn't float and overlaps model value when control has initial values

Created on 31 Dec 2018  路  8Comments  路  Source: angular/material

Bug

1.1.11 https://codepen.io/anon/pen/oJooMa

1.1.10 https://codepen.io/anon/pen/zyPPMR

CodePen and steps to reproduce the issue:

CodePen Demo which demonstrates the issue:

open https://codepen.io/anon/pen/oJooMa

Which versions of AngularJS, Material, OS, and browsers are affected?

  • AngularJS: 1.7.5
  • AngularJS Material: 1.1.11
  • OS: Fedora 29
  • Browsers: Chrome 70
urgent external contributor Pull Request fixed regression bug

Most helpful comment

I've fixed this with tests @Splaktar 馃悢 Putting in a PR now.

All 8 comments

After a bisect the offending commit is 97e2d004523d2ca5ac9b54e567d8eddc7246aae7

The specific line that seems to cause this is

ngModel.$render = delayedRender;

Changing this back to

ngModel.$render = renderMultiple;

Seems to fix the issue. I don't fully understand the purpose of this change yet so I'll do a little more digging.

Looks like the delay prevents the class md-input-has-value from being added to the md-input-container

And this can be fixed by adjusting where the md-input-has-value is evaluated within the inputCheckValue and waiting until next tick so it is in sync with the delayed render. I'll make a PR momentarily.

@codymikol thank you for looking into this! We'll want to make sure that the tests from PR https://github.com/angular/material/pull/11491 still pass and the fix doesn't cause problems with form state changing when a md-select multiple is added to a form.

@rudzikdawid what is different about your CodePen as compared to the pizza example in the docs that seems to be working fine? Is it just having multiple values selected on load that causes this?

I've fixed this with tests @Splaktar 馃悢 Putting in a PR now.

@rudzikdawid what is different about your CodePen as compared to the pizza example in the docs that seems to be working fine? Is it just having multiple values selected on load that causes this?

Main difference is the value of the model when component is initialized.
In docs model is empty, in my codePen i've passed model

$scope.selectedToppings = [
   'Pepperoni',
   'Mushrooms'
];

And then with initialized model inside controller... we can see bug in 1.1.11 release

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chriseyhorn picture chriseyhorn  路  3Comments

ghost picture ghost  路  3Comments

diogodomanski picture diogodomanski  路  3Comments

PeerInfinity picture PeerInfinity  路  3Comments

achaussende picture achaussende  路  3Comments