Material: md-autocomplete: clear selectedItem no has effect (v0.10.1-rc3)

Created on 22 Jul 2015  路  7Comments  路  Source: angular/material

Codepen here:
http://codepen.io/jros/pen/MwqZje?editors=101

Is a fork of md-autocomplete floatting label example, I have added a button to clear the selectedItem property and the control no refresh it.

To test, select an item from md-autocomplete and click clear button.
Tested on Chrome and v0.10.1-rc3

Most helpful comment

Yes, I have had to change minlength from 0 to 1 in my html to work fine.

All 7 comments

You are clearing the selected item just fine. Maybe what you are trying to do is also clear the text from the autocomplete box? To do that you should add the following to your clear method.

self.searchText = undefined;

So it looks like this:

self.clear = function(){
  self.searchText = undefined;
  self.selectedItem = undefined;
};

yes, it makes sense ...

Clearing searchText is enough.

self.clear = function(){
  self.searchText = undefined;  
};

If that is correct behavior the issue can close, is it?

The whole reset handling is still a bit buggy in my opinion.

See https://github.com/angular/material/issues/3084#issuecomment-123221872

Yes, I have had to change minlength from 0 to 1 in my html to work fine.

I'm closing this issue and grow up #3084

And if we don't want to chage minlength from 0 to 1, what can we do ?

document.activeElement.blur();

Was this page helpful?
0 / 5 - 0 ratings

Related issues

WebTechnolog picture WebTechnolog  路  3Comments

Dona278 picture Dona278  路  3Comments

ddimitrop picture ddimitrop  路  3Comments

epelc picture epelc  路  3Comments

rdantonio picture rdantonio  路  3Comments