Skip to content

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

Merged
paulpopus merged 7 commits intopayloadcms:mainfrom
aqib-io:fix/15647-bulk-upload-folder-preselect
Apr 13, 2026
Merged

fix(ui): preselect folder when bulk uploading from inside a folder#16030
paulpopus merged 7 commits intopayloadcms:mainfrom
aqib-io:fix/15647-bulk-upload-folder-preselect

Conversation

@aqib-io
Copy link
Copy Markdown
Contributor

@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
Contributor 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
Contributor 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.

@johnSmithTech

This comment was marked as spam.

@paulpopus paulpopus merged commit 71a6c60 into payloadcms:main Apr 13, 2026
322 of 324 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

🚀 This is included in version v3.83.0

milamer pushed a commit to milamer/payload that referenced this pull request Apr 20, 2026
…ayloadcms#16030)

### 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 payloadcms#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 payloadcms#15647

---------

Co-authored-by: Paul Popus <paul@payloadcms.com>
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

3 participants