Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions src/component/modals/ContributeDetails.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState, useEffect, useRef } from 'react';
import { toast } from 'react-toastify';
import axios from 'axios';
import { EXECUTION_ENGINE_URL } from '../../serverCon/config';
Expand All @@ -10,13 +10,36 @@ const ContributeDetails = ({ superState, dispatcher }) => {
const closeModal = () => {
dispatcher({ type: T.SET_CONTRIBUTE_MODAL, payload: false });
};
const [study, setStudy] = useState('');
const [path, setPath] = useState('');
const [auth, setAuth] = useState('');

const curGraph = superState.graphs[superState.curGraphIndex] ?? {};

const [study, setStudy] = useState(curGraph.projectName ?? '');
const [path, setPath] = useState(superState.uploadedDirName ?? '');
const [auth, setAuth] = useState(curGraph.authorName ?? '');
const [title, setTitle] = useState('');
const [desc, setDesc] = useState('');
const [branch, setBranch] = useState('');
const [showAdvanceOptions, setShowAdvanceOptions] = useState(false);
const prevOpenRef = useRef(false);

useEffect(() => {
if (superState.contributeModal && !prevOpenRef.current) {
const activeGraph = superState.graphs[superState.curGraphIndex] ?? {};
setStudy(activeGraph.projectName ?? '');
setPath(superState.uploadedDirName ?? '');
setAuth(activeGraph.authorName ?? '');
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On modal open you reset study/path/auth, but other form state (title, desc, branch, and possibly showAdvanceOptions) is not reset anywhere. Since this modal component is mounted persistently, those values will carry over between opens, which is inconsistent with the new “auto-fill defaults on open” behavior. Consider resetting the remaining fields when the modal opens (or when closing) to avoid stale values being shown on subsequent contributions.

Suggested change
setAuth(activeGraph.authorName ?? '');
setAuth(activeGraph.authorName ?? '');
setTitle('');
setDesc('');
setBranch('');
setShowAdvanceOptions(false);

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed with follow up PR!

setTitle('');
setDesc('');
setBranch('');
setShowAdvanceOptions(false);
}
prevOpenRef.current = superState.contributeModal;
}, [
superState.contributeModal,
superState.graphs,
superState.curGraphIndex,
superState.uploadedDirName,
]);
const submit = async (e) => {
if (study === '' || path === '' || auth === '') {
toast.info('Please Provide necessary inputs');
Expand Down