Skip to content

Commit

Permalink
Merge pull request #52 from unicef-polymer/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
adi130987 authored Mar 3, 2017
2 parents ff26f13 + 0624d16 commit 61c8df4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
8 changes: 4 additions & 4 deletions demo/demo-custom-objects-as-options.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h3>Custom objects as options and selected property with no change events</h3>
option-value="id"
option-label="option_label"
selected="{{selectedId}}"
update-selected dynamic-align style="width: 350px;"></etools-searchable-multiselection-menu>
update-selected dynamic-align empty-value style="width: 350px;"></etools-searchable-multiselection-menu>

<p><span>SelectedIDs:</span> [[_returnIdsString(selectedIds)]]</p>
<etools-searchable-multiselection-menu
Expand Down Expand Up @@ -93,9 +93,9 @@ <h3>Custom objects as options and selected property with no change events</h3>
this.set('customObjOptions', this.generateOptions());
}.bind(this), 3000);

setTimeout(function() {
this.set('selectedIds', null);
}.bind(this), 7000);
// setTimeout(function() {
// this.set('selectedIds', null);
// }.bind(this), 7000);
},

_returnIdsString: function(vals) {
Expand Down
23 changes: 17 additions & 6 deletions etools-searchable-multiselection-menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -722,22 +722,33 @@
}
},

_updateSelected: function(selectedValues) {
_updateSelected: function(selectedValues, oldSelectedValues) {
if (JSON.stringify(selectedValues) === JSON.stringify(this._prevSelectedValues)) {
return;
}
this.debounce('updateSelectedValue', function() {
if (!this.updateSelected || !selectedValues ||
Array.isArray(selectedValues) && selectedValues.length === 0) {
// do not update selected value
if (!this.updateSelected) {
return;
}
if (!this.multi) {
if (!selectedValues && !oldSelectedValues) {
return;
}
} else {
if (selectedValues === null && Array.isArray(this._prevSelectedValues) && this._prevSelectedValues.length === 0) {
return;
}
if (!this._prevSelectedValues && (!selectedValues || (Array.isArray(selectedValues) && selectedValues.length === 0))) {
return;
}
}

var selectedVals = null;
if (this.multi && Array.isArray(selectedValues)) {
if (this.multi) {
// multiselection
// selected will be empty array if selectedValues.length === 0
selectedVals = [];
if (selectedValues.length > 0) {
if (Array.isArray(selectedValues) && selectedValues.length > 0) {
selectedVals = selectedValues.map(function(s) {
return this._prepareValue(s);
}.bind(this));
Expand Down

0 comments on commit 61c8df4

Please sign in to comment.