From 3b0bea525ed2051f3635dfd6800f156601aa8c0d Mon Sep 17 00:00:00 2001
From: svishnev <shlomo-stanisla.vishnevetskiy@amdocs.com>
Date: Tue, 8 May 2018 16:15:21 +0300
Subject: nic creation issue fix

Issue-ID: SDC-1274
Change-Id: Ifd9297d3559f1b8820b0a64f063f1211b6957dd4
Signed-off-by: svishnev <shlomo-stanisla.vishnevetskiy@amdocs.com>
---
 .../src/nfvo-components/input/validation/Form.jsx    | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

(limited to 'openecomp-ui/src/nfvo-components/input/validation/Form.jsx')

diff --git a/openecomp-ui/src/nfvo-components/input/validation/Form.jsx b/openecomp-ui/src/nfvo-components/input/validation/Form.jsx
index 62fc29a55c..b5db67c027 100644
--- a/openecomp-ui/src/nfvo-components/input/validation/Form.jsx
+++ b/openecomp-ui/src/nfvo-components/input/validation/Form.jsx
@@ -70,8 +70,8 @@ class Form extends React.Component {
         return (
             <form
                 {...formProps}
-                ref={form => (this.form = form)}
-                onSubmit={event => this.handleFormValidation(event)}>
+                ref={this.setFormRef}
+                onSubmit={this.handleFormValidation}>
                 <div className="validation-form-content">
                     <fieldset disabled={isReadOnlyMode}>{children}</fieldset>
                 </div>
@@ -80,7 +80,7 @@ class Form extends React.Component {
                         labledButtons={labledButtons}
                         submitButtonText={submitButtonText}
                         cancelButtonText={cancelButtonText}
-                        ref={buttons => (this.buttons = buttons)}
+                        ref={this.setButtonsRef}
                         isReadOnlyMode={isReadOnlyMode}
                     />
                 )}
@@ -88,14 +88,19 @@ class Form extends React.Component {
         );
     }
 
-    handleFormValidation(event) {
+    handleFormValidation = event => {
         event.preventDefault();
         if (this.props.onValidateForm && !this.props.formReady) {
             return this.props.onValidateForm();
         } else {
             return this.handleFormSubmit(event);
         }
-    }
+    };
+
+    setButtonsRef = buttons => (this.buttons = buttons);
+
+    setFormRef = form => (this.form = form);
+
     handleFormSubmit(event) {
         if (event) {
             event.preventDefault();
@@ -128,7 +133,10 @@ class Form extends React.Component {
                 this.props.onValidityChanged(this.props.isValid);
             }
         }
-        if (this.props.formReady) {
+        if (
+            this.props.formReady &&
+            this.props.formReady !== prevProps.formReady
+        ) {
             // if form validation succeeded -> continue with submit
             this.handleFormSubmit();
         }
-- 
cgit 1.2.3-korg

