Skip to content

Commit fe342ff

Browse files
author
pkempenaers
committed
Adjust: select only visible options when selecting folder
1 parent 51c19d7 commit fe342ff

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/app/component/dropdownTree.service.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ export default class DropdownTreeService {
3939
return undefined;
4040
}
4141

42-
selectAllChildOptions(option, settings, currentSelection) {
43-
const optionsToAdd = this.getOptionsToAdd(option, settings, currentSelection);
42+
selectAllChildOptions(option, settings, currentSelection, searchText) {
43+
const optionsToAdd = this.getOptionsToAdd(option, settings, currentSelection, searchText);
4444

4545
if (optionsToAdd.length === 0) {
46-
this.removeAllChildOptions(option, settings, currentSelection);
46+
this.removeAllChildOptions(option, settings, currentSelection, searchText);
4747
return true;
4848
}
4949
if (settings.selectionLimit === 0) {
@@ -62,28 +62,30 @@ export default class DropdownTreeService {
6262
return false;
6363
}
6464

65-
getOptionsToAdd(option, settings, currentSelection) {
65+
getOptionsToAdd(option, settings, currentSelection, searchText) {
6666
let optionsToAdd = [];
6767
if (this.isFolder(option, settings)) {
6868
this.getChildOptions(option, settings)
6969
.forEach((childOption) => {
7070
optionsToAdd = optionsToAdd.concat(
71-
this.getOptionsToAdd(childOption, settings, currentSelection, false),
71+
this.getOptionsToAdd(childOption, settings, currentSelection, searchText),
7272
);
7373
});
74-
} else if (currentSelection.indexOf(option) < 0) {
74+
} else if (currentSelection.indexOf(option) < 0 &&
75+
this.isVisible(option, settings, searchText)) {
7576
optionsToAdd.push(option);
7677
}
7778

7879
return optionsToAdd;
7980
}
8081

81-
removeAllChildOptions(option, settings, currentSelection) {
82+
removeAllChildOptions(option, settings, currentSelection, searchText) {
8283
if (this.isFolder(option, settings)) {
8384
this.getChildOptions(option, settings).forEach((childOption) => {
84-
this.removeAllChildOptions(childOption, settings, currentSelection);
85+
this.removeAllChildOptions(childOption, settings, currentSelection, searchText);
8586
});
86-
} else if (currentSelection.indexOf(option) >= 0) {
87+
} else if (currentSelection.indexOf(option) >= 0 &&
88+
this.isVisible(option, settings, searchText)) {
8789
currentSelection.splice(currentSelection.indexOf(option), 1);
8890
}
8991
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
this.option,
4444
this.settings,
4545
this.selectedOptions,
46-
true,
46+
this.searchText,
4747
);
4848
if (selectionChanged) {
4949
this.optionClicked({ option: this.option });

0 commit comments

Comments
 (0)