Skip to content

Commit 58ea326

Browse files
author
pkempenaers
committed
Adjust: open folder when childoptions selected by selecting folder
1 parent fe342ff commit 58ea326

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/app/component/option-row/option-row.controller.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,37 @@
88
this.dropdownTreeService = dropdownTreeService;
99
this.$element = $element;
1010

11+
this.previousSelected = [];
12+
1113
if (this.isFolder()) {
1214
this.isOpen = this.dropdownTreeService
1315
.shouldFolderBeOpen(this.option, this.settings, this.selectedOptions);
1416
}
1517
}
1618

19+
$doCheck() {
20+
if (angular.isDefined(this.selectedOptions) &&
21+
!this.dropdownTreeService.areSameSelections(this.selectedOptions, this.previousSelected) &&
22+
this.isFolder()) {
23+
const newSelection = [];
24+
this.selectedOptions.forEach((selectedOption) => {
25+
if (this.previousSelected.indexOf(selectedOption) < 0) {
26+
newSelection.push(selectedOption);
27+
}
28+
});
29+
30+
this.getChildOptions().some((childOption) => {
31+
if (newSelection.indexOf(childOption) >= 0) {
32+
this.isOpen = true;
33+
return true;
34+
}
35+
return false;
36+
});
37+
38+
this.previousSelected = angular.extend([], this.selectedOptions);
39+
}
40+
}
41+
1742
getDisplayText() {
1843
return this.dropdownTreeService.getDisplayText(this.option, this.settings);
1944
}

src/app/main/main.controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
label: 'test child option c',
2121
},
2222
{
23-
name: 'f',
23+
name: 'fa',
2424
label: 'test child option f',
2525
},
2626
{

0 commit comments

Comments
 (0)