79209887

Date: 2024-11-21 06:15:44
Score: 1
Natty:
Report link

What can lead to flickering?

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.

What's solution?

  1. You can try to manage files independently. Create your own array(filesArray) with files to keep track of the selected files, instead of relying on filesField.files
  2. Modify dissmiss(): it should remove files from filesArray without modifying filesField.files, this will help to prevent triggering change event
  3. Try to update filesField.files before submission: reconstruct filesField.files from filesArray while submitting the form
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Starts with a question (0.5): What can
  • Low reputation (1):
Posted by: Islombek Salimov