diff --git a/packages/bbui/src/Form/Core/Dropzone.svelte b/packages/bbui/src/Form/Core/Dropzone.svelte index 3d803c0961..dd72167791 100644 --- a/packages/bbui/src/Form/Core/Dropzone.svelte +++ b/packages/bbui/src/Form/Core/Dropzone.svelte @@ -67,7 +67,7 @@ } $: showDropzone = - (!maximum || (maximum && value?.length < maximum)) && !disabled + (!maximum || (maximum && (value?.length || 0) < maximum)) && !disabled async function processFileList(fileList) { if ( diff --git a/packages/client/src/components/app/forms/AttachmentField.svelte b/packages/client/src/components/app/forms/AttachmentField.svelte index 70fa8717d9..63f6d2b39b 100644 --- a/packages/client/src/components/app/forms/AttachmentField.svelte +++ b/packages/client/src/components/app/forms/AttachmentField.svelte @@ -20,9 +20,12 @@ let fieldState let fieldApi + $: isSingle = schema?.type === FieldType.ATTACHMENT_SINGLE $: value = - fieldState?.value && type === FieldType.ATTACHMENT_SINGLE - ? [fieldState.value] + isSingle && !Array.isArray(fieldState?.value) + ? fieldState?.value + ? [fieldState.value] + : [] : fieldState?.value const { API, notificationStore } = getContext("sdk") @@ -72,8 +75,8 @@ const handleChange = e => { let value = e.detail - if (type === FieldType.ATTACHMENT_SINGLE) { - value = value[0] + if (isSingle) { + value = value[0] || null } const changed = fieldApi.setValue(value) if (onChange && changed) { @@ -105,7 +108,7 @@ {deleteAttachments} {handleFileTooLarge} {handleTooManyFiles} - maximum={type === FieldType.ATTACHMENT_SINGLE ? 1 : maximum} + maximum={isSingle ? 1 : maximum} {extensions} {compact} />