unclecheese/silverstripe-dropzone

bug? revertDeletion not removing <input class="input-deleted-file"...

Closed this issue · 2 comments

Hi Aaron,
I reeeally like this module, and where it's going! Many thanks for your efforts.

I am using your module from the frontend, where delete isn't enabled by default, but still... This seems to be a small bug:

file_attachment_field.js -> revertDelete() uses getHolder() to remove the <input class="input-deleted-file"...> , but that seems tp point to the wrong holder '.attached-file-inputs' (should be '.attached-file-deletions'). The following test seems to fix this:

revertDeletion: function () {
    //var del = this.getHolder().querySelector('input.input-deleted-file[value="'+this.getIdentifier()+'"]');

    var holder = this.uploader.node.querySelector('.attached-file-deletions');
    var del = holder.querySelector('input.input-deleted-file[value="'+this.getIdentifier()+'"]');

    if(del) {   
        ...

Martine

Thanks, Martine! Would you be able to submit this as a PR?

Done. Although I'm not sure if you'd not rather have the getHolder() adapted, maybe with an optional param, for clarity? Or maybe that would be overkill since this holder is only used in revertDelete...