diff --git a/src/main/resources/assets/admin/common/js/ui/selector/list/SelectableListBoxWrapper.ts b/src/main/resources/assets/admin/common/js/ui/selector/list/SelectableListBoxWrapper.ts index 4ca0f0721..b9058d905 100644 --- a/src/main/resources/assets/admin/common/js/ui/selector/list/SelectableListBoxWrapper.ts +++ b/src/main/resources/assets/admin/common/js/ui/selector/list/SelectableListBoxWrapper.ts @@ -63,7 +63,7 @@ export class SelectableListBoxWrapper }); this.listBox.onItemsRemoved((items: I[]) => { - items.forEach((item: I) => this.handleItemRemoved(item)); + this.handleItemsRemoved(items); }); this.listBox.onItemsChanged((items: I[]) => { @@ -169,9 +169,18 @@ export class SelectableListBoxWrapper 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); }