When some Ajax request occurs in same form (page) with DropzoneJS widget -> selection is cleared in drop-zone. Problem is that DropzoneJS instance is destroyed and with that current files in list (accepted and rejected) are gone.
Issue is noticed with implementation of following issue: #2823670: Improved MultiStep selection display (DropZone Widget).
And problem is introduced with following issue: #2760175: Uncaught Error: Dropzone already attached..
| Comment | File | Size | Author |
|---|---|---|---|
| #22 | 2827120_22.patch | 2.6 KB | mtodor |
| #22 | 2827120_interdiff_22_17.txt | 1.34 KB | mtodor |
| #17 | 2827120_interdiff_17_13.txt | 761 bytes | mtodor |
| #17 | 2827120_17.patch | 1.85 KB | mtodor |
| #13 | dropznejs_is_cleared_on-2827120-13.patch | 2.01 KB | chr.fritsch |
Comments
Comment #2
mtodor commentedIntegration should be refactored, but here is quick simple solution. With usage of "once()".
Comment #3
mtodor commentedComment #4
mtodor commentedComment #5
primsi commentedThanks for the work. I've tested this a bit. Everything works fine except the media entity ief widget:
1. when I drop a file and the ief forms are generated, the file doesn't get removed from dropzonejs
2. drop a second file in dropzonejs, nothing happens
Comment #6
chr.fritschWe have discovered this, too. We think the correct solution for the ief widget should be:
For multi-value fields:
For single value fields:
I guess we should handle this in an other ticket.
Comment #7
chr.fritschNew patch implements the proposed solution from comment #6.
Also a fix for #2825429: Dropzonejs in EB multi-step selection creates multiple entities is included, because i had to change the getFiles method again.
Comment #8
chr.fritschI refactored the patch a bit and fixed an issue we had with tabs.
If you were on Dropzone IEF tab and uploaded an image, then switching to another tab in eb, and then switching back, the form was broken. IEF form was there but not the file into the dropzone
Comment #9
chr.fritschFixed an issue we had if you drop the same image twice. Also i fixed coding style issues.
Comment #10
chr.fritschI'm not sure about this change.
In Thunder we have implemented a hook_file_create which could change the filename.
So to make this functionality work, i have to create a dummy file to get the actually filename.
Comment #11
chr.fritschAdded the uuid into formstate to prevent issues if there are more then one dropzones in an entity browser
Comment #12
primsi commentedSorry for the late reply,.... winter is coming and it's armed with flu and cold.
Regarding the issue from #6. The question here is what do we want from dropzonjs drop-area:
Until now DropzoneJS was treated as 2. And IMHO we should keep it this way:
Given my slower response here I will not nit-pick about this, but in further issues, if additional problems (not related to the one the the issue deals with) are discovered the way to handle this should be to open a new issue and provide a patch there. If we pile multiple issues in one patch it will be very difficult later on to navigate through what exactly happened where and why.
Comment #13
chr.fritschOk, going a few steps back.
The new patch addressed only to your comments from #5
The behavior of dropzone stays now as before.
Comment #14
primsi commentedThanks for working on that. I've tested it a bit today. The only issue I found was:
1. Drop 2 files in the ief widget where one was too big,
2. The one that is the allowed size gets removed and the one which is too big remains marked as rejected
With the other widgets the behaviour is: both files remain in the dropzone but the rejected one is marked as rejected. Which s what we want IMHO.
Comment #15
chr.fritschComment #16
mtodor commentedComment #17
mtodor commentedI have checked IEF functionality a bit. Currently there is this part of code in "modules/eb_widget/js/dropzonejs_eb_widget.ief_edit.js":
What it does is -> when ever file is dropped (or multiple of them), form is submitted over Ajax after all uploads are finished. Without changes provided in #2, that would clear DropzoneJS.
So, all we have to do is -> clear all files in drop zone, instead only valid files.
Here is patch and interdiff.
Comment #18
primsi commentedYes, the ief widget "clicks" on the submit button when queuecomplete.
Why not check in the ief widget if getRejectedFiles has something and if yes, don't trigger the mousedown? If we do it like that we have a consistent behaviour across all the widgets.
On the other hand, won't we have the same problem in #2823670: Improved MultiStep selection display (DropZone Widget)? I din't check the patch in detail yet, but we will still have to deal with "what to do if some files are rejected".
If I remember correctly we were talking about two options in IRC:
As discussed and agreed we want to avoid silently remove files if something wen't wrong.
Comment #19
mtodor commented@Primsi this ticket is not about solving IEF issues, it's about fixing bug introduced in #2760175: Uncaught Error: Dropzone already attached.. It's about making dropzonejs works properly in environment with ajax calls and need for that will happen sooner or later. Also future functionalities can prosper by using ajax.
What was my plan with this ticket (but it didn't go in that direction):
Also I think that:
Is not scope of this issue. It's related to IEF widget independently of problem we want to fix here (that issue exists also with current code base).
When it comes to #2823670: Improved MultiStep selection display (DropZone Widget), it's solved as it's visible on animated gif (first option you have listed: "accepted files are auto submitted, rejected remain in dropzone").
And to be honest, I think it would be nice to have similar functionality in IEF widget too. When you have 3 valid files and 2 invalid, that after drop you get 3 forms and 2 files stay marked as invalid in drop zone and after that you can focus on things that are important for you (filling forms for valid files) => Instead of: removing failed files, until you get all valid files in dropzone. And suddenly generation of form is triggered. Also you have to think about cases, what will happen when you drop additional invalid files if you already have all valid in dropzone, etc. I think all that are topics for other tickets.
Comment #20
primsi commentedYes I agree, this issue got derailed pretty badly. We should have stopped sooner :) We will try to do better in other issues.
I agree with most of your points in #19 and yes, this should be topic for other issues.
But anyhow, back to the point, unless I am missing something, the latest submitted patch removes all files from ief widget if one (or more) of those are bigger then max file size. And even if it removed just the ones that are bigger then max file size, IMHO we should not commit such patch because of the reason I mentioned above.
I really appreciate the work on this and I think we are close, but my opinion is that we should not add something that breaks current functionality.
Comment #21
mtodor commentedComment #22
mtodor commentedHere is solution for proposal from #18.
Basically - it will submit dropzone form, only when valid files are in dropzone.
Comment #24
primsi commentedTested and committed. Fixed two small code style nitpicks along the way. Thanks for work!