Skip to content

Commit

Permalink
pre-selected item fix
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonykoerber committed Aug 19, 2015
1 parent dc5ca59 commit d379ec5
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/mm-dropdown/mm-dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
open: function(silent) {
var inherited = BehaviorUtils.findSuper(StrandTraits.PositionableDropdown, 'open');
// Ensures that we get a value for the offsetHeight of the distributed list items:
// See Selectable behavior
if (this.maxItems) this._setMaxHeight(this.maxItems);

if (!this._widthLocked) this._lockWidth();
Expand All @@ -126,21 +125,20 @@
if(this.state === this.STATE_OPENED) this.close();
},


_selectItemByValue: function(value) {
var item = null;

value = value.toString();

if (!this._widthLocked) this._lockWidth();
this.async(function(){
var item = null;
value = value.toString();

if (this.data) {
item = this._getDataItemByValue(value);
} else {
if (!this._widthLocked) this._lockWidth();

item = this._getDomByValue(value);
}
if (item) this.selectedIndex = this.items.indexOf(item);
if (this.data) {
item = this._getDataItemByValue(value);
} else {
item = this._getDomByValue(value);
}
if (item) this.selectedIndex = this.items.indexOf(item);
});
},

_updateSelectedItem: function(e) {
Expand Down Expand Up @@ -177,7 +175,7 @@

// Data handling
_dataChanged: function(newData, oldData) {
if(newData) this._setMaxHeight(this.maxItems);
if (newData) this._setMaxHeight(this.maxItems);
if (newData && this.value) this._selectItemByValue(this.value);
},

Expand Down Expand Up @@ -316,7 +314,7 @@
},

_setMaxHeight: function(maxItems) {
actualMax = Math.min(this.items.length, maxItems);
var actualMax = Math.min(this.items.length, maxItems);

this.$.list.style.height = this.itemHeight * actualMax + 'px';

Expand Down

0 comments on commit d379ec5

Please sign in to comment.