diff --git a/projects/common/models/elements/element.ts b/projects/common/models/elements/element.ts index b1e4060356f2731f8320501f8d8aeee5e45b89e3..f33d0b19145bb739b357b83a191219b71947d162 100644 --- a/projects/common/models/elements/element.ts +++ b/projects/common/models/elements/element.ts @@ -28,7 +28,6 @@ export abstract class UIElement { constructor(element: Partial<UIElement>, ...args: unknown[]) { if (!element.type) throw Error('Element has no type!'); this.type = element.type; - if (element.id) this.id = element.id; // IDManager is an optional parameter. When given, check/repair and register the ID. if (args[0]) { @@ -37,9 +36,14 @@ export abstract class UIElement { this.id = idManager.getNewID(element.type as string); } else if (!IDManager.getInstance().isIdAvailable(element.id)) { this.id = idManager.getNewID(element.type as string); + } else { + this.id = element.id; } idManager.addID(this.id); - this.height = 1000; + } else if (element.id) { + this.id = element.id; + } else { + throw Error('No ID for element!'); } if (element.width) this.width = element.width;