From 9bda760fe0b53aa7e41769c2a55f950fc60da9e9 Mon Sep 17 00:00:00 2001
From: pkupczyk <piotr.kupczyk@id.ethz.ch>
Date: Tue, 21 Mar 2023 14:36:32 +0100
Subject: [PATCH] SSDM-13463 : Export selection of fields from tables - UI part
 - enable export options form validation after "Export" button gets clicked

---
 .../js/components/common/grid/GridExports.jsx | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/ui-admin/src/js/components/common/grid/GridExports.jsx b/ui-admin/src/js/components/common/grid/GridExports.jsx
index 6df9603d582..db689007219 100644
--- a/ui-admin/src/js/components/common/grid/GridExports.jsx
+++ b/ui-admin/src/js/components/common/grid/GridExports.jsx
@@ -38,6 +38,7 @@ class GridExports extends React.PureComponent {
     super(props)
     this.state = {
       el: null,
+      validate: false,
       importCompatibleError: null
     }
     this.handleOpen = this.handleOpen.bind(this)
@@ -57,6 +58,7 @@ class GridExports extends React.PureComponent {
 
     this.setState({
       el: null,
+      validate: false,
       importCompatibleError: null
     })
 
@@ -91,16 +93,23 @@ class GridExports extends React.PureComponent {
   handleExport() {
     const { onExport } = this.props
 
-    if (this.validate()) {
-      this.handleClose()
-      if (onExport) {
-        onExport()
+    this.setState({ validate: true }, () => {
+      if (this.validate()) {
+        this.handleClose()
+        if (onExport) {
+          onExport()
+        }
       }
-    }
+    })
   }
 
   validate() {
     const { exportable } = this.props
+    const { validate } = this.state
+
+    if (!validate) {
+      return true
+    }
 
     const isXLSExport =
       exportable.fileFormat === GridExportOptions.FILE_FORMAT.XLS
-- 
GitLab