From ea42a748cd41337e0566cfa585ddc7cd0aff331a Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Tue, 11 Jul 2023 19:51:45 +0100 Subject: [PATCH] Fix Dropzone issue changing existing photos. I used the Dropzone source code to come up with what was missing when adding existing files (we were previously reducing maxFiles which had much the same effect unless you tried to remove/add when it got quite confused); after doing that, I then discovered a PR on Dropzone which has the same fixes: https://github.com/dropzone/dropzone/pull/2003 --- web/cobrands/fixmystreet/fixmystreet.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js index 591e21b67c0..8494b57bb6a 100644 --- a/web/cobrands/fixmystreet/fixmystreet.js +++ b/web/cobrands/fixmystreet/fixmystreet.js @@ -887,7 +887,7 @@ $.extend(fixmystreet.set_up, { if (!f) { return; } - var mockFile = { name: f, server_id: f, dataURL: '/photo/temp.' + f }; + var mockFile = { name: f, server_id: f, dataURL: '/photo/temp.' + f, status: Dropzone.SUCCESS, accepted: true }; photodrop.emit("addedfile", mockFile); photodrop.createThumbnailFromUrl(mockFile, photodrop.options.thumbnailWidth, photodrop.options.thumbnailHeight, @@ -895,7 +895,9 @@ $.extend(fixmystreet.set_up, { photodrop.emit('thumbnail', mockFile, thumbnail); }); photodrop.emit("complete", mockFile); - photodrop.options.maxFiles -= 1; + photodrop.files.push(mockFile); + photodrop._updateMaxFilesReachedClass(); + prevFile = mockFile; }); }); });