From b8661a4ea889100ef22a85be02736407768c7580 Mon Sep 17 00:00:00 2001
From: rhenck <richard.henck@iqb.hu-berlin.de>
Date: Mon, 28 Feb 2022 12:54:58 +0100
Subject: [PATCH] Fix (both) text field formControls to handle the initial
 value correctly

---
 .../components/ui-elements/text-field-simple.component.ts     | 2 +-
 .../common/components/ui-elements/text-field.component.ts     | 4 ++--
 .../common/directives/form-element-component.directive.ts     | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/projects/common/components/ui-elements/text-field-simple.component.ts b/projects/common/components/ui-elements/text-field-simple.component.ts
index fd73a4e8d..f1b539910 100644
--- a/projects/common/components/ui-elements/text-field-simple.component.ts
+++ b/projects/common/components/ui-elements/text-field-simple.component.ts
@@ -17,7 +17,7 @@ import { TextFieldSimpleElement } from '../../interfaces/elements';
            [style.text-decoration]="elementModel.styles.underline ? 'underline' : ''"
            [readonly]="elementModel.readOnly"
            [formControl]="elementFormControl"
-           value="{{elementModel.value}}">
+           [value]="elementModel.value">
   `,
   styles: [
     'input {border: 1px solid rgba(0,0,0,.12); border-radius: 5px}'
diff --git a/projects/common/components/ui-elements/text-field.component.ts b/projects/common/components/ui-elements/text-field.component.ts
index c14cc498f..90885d18e 100644
--- a/projects/common/components/ui-elements/text-field.component.ts
+++ b/projects/common/components/ui-elements/text-field.component.ts
@@ -22,7 +22,7 @@ import { TextFieldElement } from '../../interfaces/elements';
       <mat-label>{{elementModel.label}}</mat-label>
       <input matInput type="text" #input autocomplete="off"
              [formControl]="elementFormControl"
-             value="{{elementModel.value}}"
+             [value]="elementModel.value"
              [pattern]="elementModel.pattern"
              [readonly]="elementModel.readOnly"
              (focus)="elementModel.inputAssistancePreset !== 'none' ? onFocusChanged.emit(input) : null"
@@ -51,7 +51,7 @@ import { TextFieldElement } from '../../interfaces/elements';
         [appearance]="$any(elementModel.appearance)">
       <input matInput type="text" #input autocomplete="off"
              [formControl]="elementFormControl"
-             [value]="$any(elementModel.value)"
+             [value]="elementModel.value"
              [readonly]="elementModel.readOnly"
              [pattern]="elementModel.pattern"
              (focus)="elementModel.inputAssistancePreset !== 'none' ? onFocusChanged.emit(input) : null"
diff --git a/projects/common/directives/form-element-component.directive.ts b/projects/common/directives/form-element-component.directive.ts
index 6de0d27be..8a833fd32 100644
--- a/projects/common/directives/form-element-component.directive.ts
+++ b/projects/common/directives/form-element-component.directive.ts
@@ -8,8 +8,8 @@ export abstract class FormElementComponent extends ElementComponent implements O
   elementFormControl!: FormControl;
 
   ngOnInit(): void {
-    this.elementFormControl = (this.parentForm) ?
+    this.elementFormControl = this.parentForm ?
       this.parentForm.controls[this.elementModel.id] as FormControl :
-      new FormControl({});
+      new FormControl(this.elementModel.value);
   }
 }
-- 
GitLab