The issue you're experiencing arises from the way the change
event is triggered and handled when you modify filesField.files
in the dismiss()
. Specifically, when you remove a file and update filesField.files
, it triggers the change
event, which in turn causes your change event listener to recreate the entire file list.
This results in flickering and the unexpected removal of elements from the DOM during drag-and-drop operations.
filesArray
) with files to keep track of the selected files, instead of relying on filesField.files
dissmiss()
: it should remove files from filesArray
without modifying filesField.files
, this will help to prevent triggering change
eventfilesField.files
before submission: reconstruct filesField.files
from filesArray
while submitting the form