Skip to content

Commit

Permalink
fix: don't set group as selected when all it's children selected
Browse files Browse the repository at this point in the history
  • Loading branch information
varnastadeus committed Aug 31, 2018
1 parent f67fb61 commit 5f63d13
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 18 deletions.
14 changes: 0 additions & 14 deletions src/ng-select/items-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,6 @@ describe('ItemsList', () => {
expect(list.filteredItems.length).toBe(3);
});

it('should select group when all group children are selected', () => {
cmp.hideSelected = true;
cmp.groupBy = 'groupKey';
list.setItems([
{ label: 'K1', val: 'V1', groupKey: 'G1' },
{ label: 'K2', val: 'V2', groupKey: 'G1' },
]);
list.select(list.items[1]); // K1
list.select(list.items[2]); // K2

expect(list.selectedItems.length).toBe(1);
expect(list.selectedItems[0].label).toBe('G1');
});

it('should remove all group and group children items if group is selected when hideSelected=true', () => {
cmp.hideSelected = true;
cmp.groupBy = 'groupKey';
Expand Down
4 changes: 0 additions & 4 deletions src/ng-select/selection-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ export class SelectionModel {
const childrenCount = item.parent.children.length;
const selectedCount = item.parent.children.filter(x => x.selected).length;
item.parent.selected = childrenCount === selectedCount;
if (item.parent.selected && groupAsModel) {
this._removeChildren(item.parent);
this._selected = [...this._selected, item.parent];
}
} else if (item.children) {
this._setChildrenSelectedState(item.children, true);
this._removeChildren(item);
Expand Down

0 comments on commit 5f63d13

Please sign in to comment.