Skip to content

fix: preserve accumulated files in the Update Selected Questions modal#136

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-file-upload-widget-issue
Draft

fix: preserve accumulated files in the Update Selected Questions modal#136
Copilot wants to merge 3 commits intomainfrom
copilot/fix-file-upload-widget-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 25, 2026

The file upload widget in the "Update Selected Questions" modal was replacing the FileList on each picker open, making it impossible to build up a multi-file selection incrementally. The same DataTransfer-based accumulator pattern already used in new.html was absent from update_modal.html.

Changes

  • update_modal.html
    • Adds a fileAccumulator (DataTransfer) scoped to the modal's JS closure.
    • fileUpload change handler now appends newly-picked files into the accumulator and writes the accumulated FileList back to the input — instead of replacing.
    • renderAccumulatedFileList() renders per-file badge+remove buttons below the input using textContent (XSS-safe).
    • removeAccumulatedFile(name) rebuilds the accumulator without the named file.
    • clearFileAccumulator() resets accumulator, input, and rendered list; called on modal hidden.bs.modal and Cancel click (replacing the previous bare fileUpload.value = '').
    • isFileSelected() now checks fileAccumulator.files.length instead of fileUpload.files.length.
// Before — each picker open replaced the previous selection
fileUpload.addEventListener('change', function() {
  if (updateModal.classList.contains('show')) {
    updateSaveButtonState();
  }
});

// After — files are accumulated across picker opens
fileUpload.addEventListener('change', function() {
  Array.from(this.files).forEach(f => fileAccumulator.items.add(f));
  fileUpload.files = fileAccumulator.files;
  renderAccumulatedFileList();
  if (updateModal.classList.contains('show')) updateSaveButtonState();
});

Copilot AI and others added 2 commits April 25, 2026 17:28
…across picker opens

Agent-Logs-Url: https://github.com/johannehouweling/ToxTempAssistant/sessions/2e5c6a18-6c34-49ac-9c7c-ac81c27a4eb4

Co-authored-by: johannehouweling <95692173+johannehouweling@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix file upload widget forgetting previously selected files fix: preserve accumulated files in the Update Selected Questions modal Apr 25, 2026
Copilot AI requested a review from johannehouweling April 25, 2026 17:29
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.

File upload widget forgets previously selected files

2 participants