Only allow model view components to be added once (#1458)

This commit is contained in:
Matt Irvine
2018-05-22 13:06:00 -07:00
committed by GitHub
parent 6aac0b6056
commit 40db0d6f6f

View File

@@ -156,6 +156,9 @@ export abstract class ContainerBase<T> extends ComponentBase {
/// IComponent container-related implementation
public addToContainer(componentDescriptor: IComponentDescriptor, config: any): void {
if (this.items.some(item => item.descriptor.id === componentDescriptor.id && item.descriptor.type === componentDescriptor.type)) {
return;
}
this.items.push(new ItemDescriptor(componentDescriptor, config));
this.modelStore.eventuallyRunOnComponent(componentDescriptor.id, component => component.registerEventHandler(event => {
if (event.eventType === ComponentEventType.validityChanged) {