1- import React , { useState , useEffect } from 'react' ;
1+ import React , { useState , useEffect , useRef } from 'react' ;
22import { toast } from 'react-toastify' ;
33import axios from 'axios' ;
44import { EXECUTION_ENGINE_URL } from '../../serverCon/config' ;
@@ -20,15 +20,26 @@ const ContributeDetails = ({ superState, dispatcher }) => {
2020 const [ desc , setDesc ] = useState ( '' ) ;
2121 const [ branch , setBranch ] = useState ( '' ) ;
2222 const [ showAdvanceOptions , setShowAdvanceOptions ] = useState ( false ) ;
23+ const prevOpenRef = useRef ( false ) ;
2324
2425 useEffect ( ( ) => {
25- if ( superState . contributeModal ) {
26+ if ( superState . contributeModal && ! prevOpenRef . current ) {
2627 const activeGraph = superState . graphs [ superState . curGraphIndex ] ?? { } ;
2728 setStudy ( activeGraph . projectName ?? '' ) ;
2829 setPath ( superState . uploadedDirName ?? '' ) ;
2930 setAuth ( activeGraph . authorName ?? '' ) ;
31+ setTitle ( '' ) ;
32+ setDesc ( '' ) ;
33+ setBranch ( '' ) ;
34+ setShowAdvanceOptions ( false ) ;
3035 }
31- } , [ superState . contributeModal ] ) ;
36+ prevOpenRef . current = superState . contributeModal ;
37+ } , [
38+ superState . contributeModal ,
39+ superState . graphs ,
40+ superState . curGraphIndex ,
41+ superState . uploadedDirName ,
42+ ] ) ;
3243 const submit = async ( e ) => {
3344 if ( study === '' || path === '' || auth === '' ) {
3445 toast . info ( 'Please Provide necessary inputs' ) ;
0 commit comments