Skip to content

4218-uploads-not-displaying-on-parts-review-page clear stale files state when part form modals close#4224

Open
RemainingDelta wants to merge 1 commit into
developfrom
4218-uploads-not-displaying-on-parts-review-page
Open

4218-uploads-not-displaying-on-parts-review-page clear stale files state when part form modals close#4224
RemainingDelta wants to merge 1 commit into
developfrom
4218-uploads-not-displaying-on-parts-review-page

Conversation

@RemainingDelta
Copy link
Copy Markdown
Contributor

@RemainingDelta RemainingDelta commented May 20, 2026

Changes

Fixed a bug in SubmissionFormModal and ReviewFormModal where uploaded file names would not appear after form submission. NERFormModal resets the RHF fileIdsfield array on every close, but the parallel local files: File[] state was never cleared. On re-open, the length mismatch caused the file list to not render. Added a useEffect in both modals that resets files (and selectedPartIndex in ReviewFormModal) whenever open becomes false.

Test Cases

  • Repeat several times to ensure the fix works
    • Upload files in New Submission modal (Projects -> Specific Project -> Part Review -> New -> New Submission) — file names appear in the list
    • Submit the form, re-open New Submission — file list is empty with no stale entries
    • Upload a new file on re-open — correct file name appears

Screenshots

Before

Note: This sometimes happens, not always
A file is uploaded, but it doesn't show file name
New Submission
All Parts for Impact Attessatel

After

A file is uploaded, but it always shows file name:
New Submission
All Parts for legact Altengate

Closes #4218

@staysgt staysgt self-requested a review May 20, 2026 20:01
Copy link
Copy Markdown
Contributor

@staysgt staysgt left a comment

Choose a reason for hiding this comment

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

Good job!

@staysgt staysgt requested a review from wavehassman May 20, 2026 20:02
Copy link
Copy Markdown
Contributor

@wavehassman wavehassman left a comment

Choose a reason for hiding this comment

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

Great job fixing the bug! I would just prefer it to be structured differently

const [uploading, setUploading] = useState(false);
const { mutateAsync: uploadFile } = useUploadFile();

useEffect(() => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of a useEffect in both files, just wrap handleClose in a callback that also clears the state. Then update the onHide= call. It should look something like this:

const handleCloseAndReset = () => {
  setFiles([]);
  setSelectedPartIndex(undefined); 
  handleClose();
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Maintenance] - Uploads not displaying on Parts Review page

3 participants