From 3d7744b33e938db41a2d1b7be55ee1db2f21ed83 Mon Sep 17 00:00:00 2001
From: Zoltan Runyo <zoltan.runyo@ess.eu>
Date: Tue, 22 Mar 2022 10:05:28 +0100
Subject: [PATCH] ICSHWI-8790: Auto-completes: if there only is a single option
 available, select it on blur

---
 src/components/IOC/IOCCreateDialog.js | 2 ++
 src/components/IOC/IOCDeployDialog.js | 2 ++
 src/components/IOC/IOCDetailAdmin.js  | 6 +++++-
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/components/IOC/IOCCreateDialog.js b/src/components/IOC/IOCCreateDialog.js
index ccfd8512..31ca8e2a 100644
--- a/src/components/IOC/IOCCreateDialog.js
+++ b/src/components/IOC/IOCCreateDialog.js
@@ -52,6 +52,7 @@ export function IOCCreateDialog({ open, setOpen, submitCallback, error, resetErr
             renderInput={(params) => <TextField {...params} label="IOC name" variant="outlined" required/>}
             onChange={(event, value, reason) => {setName(value); resetError();}}
             onInputChange={(event, value, reason) => {event && onNameKeyUp(event.nativeEvent)}}
+            autoSelect
           />
 
           <TextField autoComplete="off" className={classes.textField} id="description" label="--- IOC Description from CCDB ---"
@@ -69,6 +70,7 @@ export function IOCCreateDialog({ open, setOpen, submitCallback, error, resetErr
             getOptionLabel={(option) => {return option.url}}
             onChange={(event, value, reason) => {setGitId(value.id); resetError();}}
             renderInput={(params) => <TextField {...params} label="Git repository" variant="outlined" fullWidth required />}
+            autoSelect
           />
 
           {error ?
diff --git a/src/components/IOC/IOCDeployDialog.js b/src/components/IOC/IOCDeployDialog.js
index 2a95d5ff..db76b1e5 100644
--- a/src/components/IOC/IOCDeployDialog.js
+++ b/src/components/IOC/IOCDeployDialog.js
@@ -71,6 +71,7 @@ export function IOCDeployDialog({ open, setOpen, submitCallback, hasActiveDeploy
             onChange={(event, value, reason) => {setGitVersion(value?.reference); resetError();}}
             disabled={(!gitRepo) || (gitRepo.trim() === "")}
             renderInput={(params) => <TextField {...params} label="Git reference" variant="outlined" fullWidth required />}
+            autoSelect
           />
 
           <Autocomplete
@@ -84,6 +85,7 @@ export function IOCDeployDialog({ open, setOpen, submitCallback, hasActiveDeploy
             onChange={(event, value, reason) => {setHost(value); resetError();}}
             onInputChange={(event, value, reason) => {event && onHostKeyUp(event.nativeEvent)}}
             disabled={hasActiveDeployment}
+            autoSelect
           />
 
           { hasActiveDeployment ? 
diff --git a/src/components/IOC/IOCDetailAdmin.js b/src/components/IOC/IOCDetailAdmin.js
index 75157e31..301a1818 100644
--- a/src/components/IOC/IOCDetailAdmin.js
+++ b/src/components/IOC/IOCDetailAdmin.js
@@ -106,6 +106,7 @@ export default function IOCDetailAdmin({ ioc, getIOC, resetTab, buttonDisabled }
                         onChange={(event, value, reason) => { setName(value); setError(null); }}
                         onInputChange={(event, value, reason) => { event && onNameKeyUp(event.nativeEvent) }}
                         disabled={disabled}
+                        autoSelect
                     />
                 </span>
             </Tooltip>
@@ -124,6 +125,7 @@ export default function IOCDetailAdmin({ ioc, getIOC, resetTab, buttonDisabled }
                 renderInput={(params) => <TextField {...params} label="Owner" variant="outlined" fullWidth required />}
                 onChange={(event, value, reason) => {setOwner(value); setError(null);}}
                 disabled={disabled}
+                autoSelect
             />
         );
     }
@@ -158,7 +160,9 @@ export default function IOCDetailAdmin({ ioc, getIOC, resetTab, buttonDisabled }
                         } }
                         getOptionLabel={(option) => { return option.url }}
                         onChange={(event, value, reason) => {setGitId(value.id); setError(null);}}
-                        renderInput={(params) => <TextField {...params} label="Git repository" variant="outlined" fullWidth required />} />
+                        renderInput={(params) => <TextField {...params} label="Git repository" variant="outlined" fullWidth required />} 
+                        autoSelect
+                        />
 
                     <AccessControl 
                         allowedRoles={["DeploymentToolAdmin"]}
-- 
GitLab