Skip to content

Commit 31e2179

Browse files
authored
fix(ui): execute client upload handler only when file exists (#11538)
Fixes #11537
1 parent 8f203bb commit 31e2179

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

packages/ui/src/elements/BulkUpload/FormsManager/createFormData.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ export async function createFormData(
1818
delete data.file
1919
}
2020

21-
let clientUploadContext = null
22-
23-
if (typeof uploadHandler === 'function') {
21+
if (file && typeof uploadHandler === 'function') {
2422
let filename = file.name
25-
clientUploadContext = await uploadHandler({
23+
24+
const clientUploadContext = await uploadHandler({
2625
file,
2726
updateFilename: (value) => {
2827
filename = value

packages/ui/src/forms/Form/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,9 @@ export const Form: React.FC<FormProps> = (props) => {
507507

508508
const handler = getUploadHandler({ collectionSlug })
509509

510-
if (typeof handler === 'function') {
511-
let clientUploadContext = null
510+
if (file && typeof handler === 'function') {
512511
let filename = file.name
513-
clientUploadContext = await handler({
512+
const clientUploadContext = await handler({
514513
file,
515514
updateFilename: (value) => {
516515
filename = value

0 commit comments

Comments
 (0)