Skip adding empty list of items (#14084)

This commit is contained in:
Charles Gagnon
2021-01-28 09:08:40 -08:00
committed by GitHub
parent 8677ffc68c
commit ff6f30505c

View File

@@ -103,6 +103,11 @@ export abstract class ViewBase extends AngularDisposable implements IModelView {
}
addToContainer(containerId: string, items: { itemConfig: IItemConfig, index?: number }[], initial?: boolean): void {
if (items.length === 0) {
// If we don't have any items save ourselves the time and just exit early. This can happen when
// an item is defined since we may have components definitions which have empty itemConfigs
return;
}
const itemNames = items.map(item => item.itemConfig.componentShape.id).join(',');
this.logService.debug(`Queueing action to add components ${itemNames} to container ${containerId}`);
// Do not return the promise as this should be non-blocking