Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

Error when multiple is activated and options do not all have children #227

Merged
merged 1 commit into from
Mar 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions src/inputs/multiple.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,16 @@ var callSuper = Selectivity.inherits(MultipleInput, Selectivity, {
* @inherit
*/
filterResults: function(results) {
var hasChildren = results.some(function(item) {
return item.children;
});
if (hasChildren) {
results = results.map(function(item) {
return {
id: item.id,
text: item.text,
children: this.filterResults(item.children)
};
}, this);
}
results = results.map(function(item) {
var result = {
id: item.id,
text: item.text
};
if (item.children) {
result['children'] = this.filterResults(item.children);
}
return result;
}, this);

return results.filter(function(item) {
return !Selectivity.findById(this._data, item.id);
Expand Down