Skip to content

Commit

Permalink
Misc changes for the new tree- and -list api #3696
Browse files Browse the repository at this point in the history
  • Loading branch information
ashklianko committed Sep 13, 2024
1 parent b14d631 commit 5b04818
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export class ListSelectionController<I>
if (this.isChecked() || this.isPartial()) {
this.selectableListBox.deselectAll();
} else {
this.selectableListBox.setSelectionMode(SelectionMode.SELECT);
this.selectableListBox.selectAll();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,7 @@ export class SelectableListBoxWrapper<I>
const itemId = this.listBox.getIdOfItem(item);
const actualItem = this.listBox.getItem(itemId) || item; // making sure we work with actual list item value

if (!this.isMultiSelect() || this.selectionMode === SelectionMode.HIGHLIGHT) { // unselect all other items
this.getCurrentlySelectedItems().filter((selectedItem) => this.listBox.getIdOfItem(selectedItem) !== itemId).forEach(
(selectedItem: I) => {
this.handleUserDeselected(selectedItem);
});
}
this.unSelectOtherItems(itemId);

if (this.isSelected(itemId)) {
this.handleUserDeselected(actualItem);
Expand All @@ -145,6 +140,15 @@ export class SelectableListBoxWrapper<I>
}
}

private unSelectOtherItems(itemId: string): void {
if (!this.isMultiSelect() || this.selectionMode === SelectionMode.HIGHLIGHT) { // unselect all other items
this.getCurrentlySelectedItems().filter((selectedItem) => this.listBox.getIdOfItem(selectedItem) !== itemId).forEach(
(selectedItem: I) => {
this.handleUserDeselected(selectedItem);
});
}
}

protected getCurrentlySelectedItems(): I[] {
return Array.from(this.selectedItems.values());
}
Expand Down

0 comments on commit 5b04818

Please sign in to comment.