Order of the files in File Upload is not honored
The File Upload field in the Filament Form Builder does not preserve the order of files. Instead of maintaining the order in which the images are arranged in the gallery, the final order appears to be based on the upload completion time. Since files are uploaded in batches of two, the images that finish uploading first appear first in the final order once the form is saved.
This issue occurs when the user clicks the Save button. Visually, the user sees the images in a specific order before saving, but after saving, the order changes, causing confusion.
This is how i have the Form Field. Did I miss some attribute like preserveFileOrder or something like that? I can't seem to find what I'm doing wrong.
Solution:Jump to solution
I just saw there's already an open issue for this bug, so I don't think this post makes much sense in the help forum anymore. Sorry for not checking that earlier—I thought it was a config issue on my end. Thanks for the help, @toeknee . We'll set MaxParallelUpload to 1 for now and I'll check if I can contribute with a PR.
https://github.com/filamentphp/filament/issues/15308
Edit:...
5 Replies
That's always going to be the case.. Filepond batch uploads for speed, but not in sequential order. I suppose you need to adjust the maxParallelUploads. default is 2 so use: ->maxParallelUploads(1)
So, in this case, the issue would be with FilePond, right? And would there be a way to save the initial order somewhere (another property, state, or variable) before the model is saved?
I mean, visually, we have the correct order. If I could store it and then reorder the images in the observer, that could be a possible solution.
I mean, visually, we have the correct order. If I could store it and then reorder the images in the observer, that could be a possible solution.
But if you set the maxParallelUploads(1) then it will upload and add to the array in order of uploaded I beleive.
Hi, sorry for the late reply. In our case, the users upload lot of images at time, so it is not practical for us to have them get on one by one.
I tried the hook
afterStateUpdated
and reorderUploadedFilesUsing
but with no luck. AfterStateUpdated
doesn't seem to log when the user reorder or delete the images in the field, only when uploads a new image. And reorderUploadedFilesUsing
only triggers once the user save the resource and with the files already ordered in wrong way.
I also tried to get the order via Alpine extraAttributes
, with no lucl. Only fires on uploading new files, not on reordering.
Solution
I just saw there's already an open issue for this bug, so I don't think this post makes much sense in the help forum anymore. Sorry for not checking that earlier—I thought it was a config issue on my end. Thanks for the help, @toeknee . We'll set MaxParallelUpload to 1 for now and I'll check if I can contribute with a PR.
https://github.com/filamentphp/filament/issues/15308
Edit:
I made my first PR 🥳. Hoping all is good
https://github.com/filamentphp/filament/pull/15923