From 13965616d1a93de2b9d09d9373530702f3dcbd0f Mon Sep 17 00:00:00 2001 From: Joshua Sigona Date: Thu, 12 Aug 2021 21:58:22 +0900 Subject: [PATCH 1/2] Fix Nico not showing up all the time. --- src/DEFAULTS.js | 2 +- src/TestPanel.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DEFAULTS.js b/src/DEFAULTS.js index aee0955..cb75e80 100644 --- a/src/DEFAULTS.js +++ b/src/DEFAULTS.js @@ -2,7 +2,7 @@ const NICONICONII = process.env.PUBLIC_URL+"/icons/nicodotpng.png.png" function DisplayIcon(icon) { //console.log(icon) - return icon?process.env.PUBLIC_URL+icon:NICONICONII + return icon&&icon.length>0?process.env.PUBLIC_URL+icon:NICONICONII } export {NICONICONII,DisplayIcon}; \ No newline at end of file diff --git a/src/TestPanel.js b/src/TestPanel.js index 8c2c2c7..4d16695 100644 --- a/src/TestPanel.js +++ b/src/TestPanel.js @@ -595,7 +595,7 @@ AUGMENT }} /> - Date: Thu, 12 Aug 2021 22:25:19 +0900 Subject: [PATCH 2/2] Sometimes it's as simple as using blur() --- src/App.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/App.js b/src/App.js index ae706f7..0342d8c 100644 --- a/src/App.js +++ b/src/App.js @@ -6,7 +6,7 @@ import Toggle from 'react-toggle' //Tooltip props: http://aaronshaf.github.io/re import Helmet from 'react-helmet' import { ExpandTooltip } from './components/ExpandTooltip'; -import {XSquareFill, PlusCircle, LifePreserver, Server, CloudUploadFill} from 'react-bootstrap-icons' +import {XSquareFill, PlusCircle, LifePreserver, Server, CloudUploadFill, PatchCheck} from 'react-bootstrap-icons' import { HashRouter, @@ -118,6 +118,14 @@ function TableEditor(p) { const [importAllowed,setImportAllowed] = useState(false) const [fileData,setFileData] = useState(undefined) const [lockSubmission,setLockSubmission] = useState(false) + + function patchValue(value,p,col,dat) { + return axios.patch(p.BACKENDURL+p.path,{ + [col.name]:value==="null"?null:value, + id:dat.id, + pass:p.password + }) + } function SubmitBoxes() { if (!lockSubmission) { @@ -135,10 +143,6 @@ function TableEditor(p) { }) } } - - useGlobalKeyDown(()=>{ - SubmitBoxes() - },['Enter']) useEffect(()=>{ setUpdate(true) @@ -216,13 +220,7 @@ function TableEditor(p) { (f)=>{setSubmitVal({field:col.name,value:f});}}/>})}{SubmitBoxes()}} className="submitbutton"/>} {data.map((dat)=> {axios.delete(p.BACKENDURL+p.path,{data:{id:dat.id,pass:p.password}}).then(()=>{setUpdate(true)}).catch((err)=>{alert(err.response.data)})}}/>{fields.map((col,i)=> - { - return axios.patch(p.BACKENDURL+p.path,{ - [col.name]:value==="null"?null:value, - id:dat.id, - pass:p.password - }) - }} value={String(dat[col.name])}/>)})} + patchValue(value,p,col,dat)} callback2={(f,value)=>{if (f.key==='Enter') {f.currentTarget.blur()} else {return 'Chill'}}} value={String(dat[col.name])}/>)})} :<>}