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 23, 2024
1 parent ef4f406 commit 0729282
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class SelectableListBoxWrapper<I>
});

this.listBox.onItemsRemoved((items: I[]) => {
items.forEach((item: I) => this.handleItemRemoved(item));
this.handleItemsRemoved(items);
});

this.listBox.onItemsChanged((items: I[]) => {
Expand Down Expand Up @@ -169,9 +169,18 @@ export class SelectableListBoxWrapper<I>
this.select(item);
}

protected handleItemsRemoved(items: I[]): void {
const selectedItems = items.filter((item: I) => this.isItemSelected(item));

if (selectedItems.length > 0) {
this.deselect(selectedItems);
}

items.forEach((item: I) => this.handleItemRemoved(item));
}

protected handleItemRemoved(item: I): void {
const id: string = this.listBox.getIdOfItem(item);
this.selectedItems.delete(id);
this.itemsWrappers.get(id)?.forEach((wrapper) => wrapper.remove());
this.itemsWrappers.delete(id);
}
Expand Down

0 comments on commit 0729282

Please sign in to comment.