From 63fc058e8387a4624d875bc7cb1a26b704d67dc3 Mon Sep 17 00:00:00 2001
From: rhenck <richard.henck@iqb.hu-berlin.de>
Date: Thu, 20 Jan 2022 17:06:56 +0100
Subject: [PATCH] [editor] Fix cloze dropList properties references

Do not change the underlying temp object, but instead use an new object
reference.
This avoids changing references to objects of other elements.
---
 .../element-model-properties.component.ts          | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/projects/editor/src/app/components/unit-view/page-view/properties-panel/element-model-properties.component.ts b/projects/editor/src/app/components/unit-view/page-view/properties-panel/element-model-properties.component.ts
index e657bf2b9..bd5845b3a 100644
--- a/projects/editor/src/app/components/unit-view/page-view/properties-panel/element-model-properties.component.ts
+++ b/projects/editor/src/app/components/unit-view/page-view/properties-panel/element-model-properties.component.ts
@@ -30,10 +30,9 @@ export class ElementModelPropertiesComponent {
   constructor(public unitService: UnitService) { }
 
   addOption(property: string, value: string): void {
-    (this.combinedProperties[property] as string[]).push(value);
     this.updateModel.emit({
       property: property,
-      value: [...this.combinedProperties[property] as string[]]
+      value: [...(this.combinedProperties[property] as string[]), value]
     });
   }
 
@@ -55,13 +54,10 @@ export class ElementModelPropertiesComponent {
   }
 
   addDropListOption(value: string): void {
-    const id = this.unitService.getNewValueID();
-    if (this.combinedProperties.value) {
-      this.combinedProperties.value.push({ stringValue: value, id: id });
-    } else {
-      this.combinedProperties.value = [{ stringValue: value, id: id }];
-    }
-    this.updateModel.emit({ property: 'value', value: this.combinedProperties.value });
+    this.updateModel.emit({
+      property: 'value',
+      value: [...this.combinedProperties.value, { stringValue: value, id: this.unitService.getNewValueID() }]
+    });
   }
 
   async editDropListOption(optionIndex: number): Promise<void> {
-- 
GitLab