From a499da74261480643fdecfef4c3dce293b87afb8 Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Tue, 10 Dec 2019 14:26:56 +0100
Subject: [PATCH] Fix #343 - empty field now updates model with undefined

---
 .../components/generic-input/generic-input.component.ts  | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/app/components/generic-input/generic-input.component.ts b/src/app/components/generic-input/generic-input.component.ts
index 0e946cfed..5261e58a9 100644
--- a/src/app/components/generic-input/generic-input.component.ts
+++ b/src/app/components/generic-input/generic-input.component.ts
@@ -244,8 +244,13 @@ export abstract class GenericInputComponent implements OnChanges {
      * met à jour le modèle d'après la saisie
      */
     public updateModelFromUI() {
-        if (this.validateUI()) {
-            this.setAndValidateModel(this, +this._uiValue); // cast UI value to Number
+        const valid = this.validateUI();
+        if (valid || this._uiValue === "") {
+            let val: number; // = undefined
+            if (valid) {
+                val = +this._uiValue; // cast UI value to Number
+            }
+            this.setAndValidateModel(this, val);
         }
     }
 
-- 
GitLab