Skip to content

fix(ui): preselect folder when bulk uploading from inside a folder#16030

Open
aqib-io wants to merge 2 commits intopayloadcms:mainfrom
aqib-io:fix/15647-bulk-upload-folder-preselect
Open

fix(ui): preselect folder when bulk uploading from inside a folder#16030
aqib-io wants to merge 2 commits intopayloadcms:mainfrom
aqib-io:fix/15647-bulk-upload-folder-preselect

Conversation

@aqib-io
Copy link
Copy Markdown

@aqib-io aqib-io commented Mar 22, 2026

What?

Preselect the current folder when triggering bulk upload from inside a folder view.

Why?

When bulk uploading from inside a folder, all files show "No Folder" instead of the current folder. Users have to manually assign each file to the folder, which is tedious and easy to miss. See #15647

How?

  • Added folderID to BulkUploadContext to pass folder state from the button to the drawer
  • In ListBulkUploadButton, read folderID from useFolder() and set it on the context when opening bulk upload
  • In FormsManager, inject the folderID into each form's initial state so the folder field is pre-populated

Fixes #15647

@aqib-io
Copy link
Copy Markdown
Author

aqib-io commented Mar 23, 2026

nit: BulkUploadContext types folderID as number|string but state and defaults use undefined; worth aligning the type (e.g. optional) so strict TS consumers do not get impossible required-field errors.

Good catch. updated folderID to optional. Thanks for the review!

@aqib-io
Copy link
Copy Markdown
Author

aqib-io commented Mar 23, 2026

Approach looks right — passing the current folderID from useFolder() into the bulk upload context so newly uploaded files land in the correct folder. One thing to watch: folderFieldName defaults to undefined if folders config is missing. That guard on line 108 (folderID && folderFieldName && baseState?.[folderFieldName]) handles it, but worth confirming the setFolderID(undefined) reset on drawer close doesn't cause issues if the folder context changes between opens.

Thanks! Confirmed — setFolderID(undefined) resets the state when the drawer closes, and on the next open, ListBulkUploadButton sets the fresh folderID from useFolder() before opening the modal. So if the user navigates to a different folder and opens bulk upload again, it picks up the new folder correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bulk Upload does not preselect folder when triggered from inside a folder

1 participant