Skip to content

Commit

Permalink
Fixes: Mobile - Cannot add new files, if FieldFile is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Mar 17, 2023
1 parent 21ca6f6 commit ec7d3d2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Expand Up @@ -39,7 +39,10 @@ const removeFileMutation = new MutationHandler(
const removeFileLoading = addFileMutation.loading()
const canInteract = computed(
() => !addFileLoading.value && !removeFileLoading.value,
() =>
!props.context.disabled &&
!addFileLoading.value &&
!removeFileLoading.value,
)
const fileInput = ref<HTMLInputElement>()
Expand Down
Expand Up @@ -238,4 +238,20 @@ describe('Fields - FieldFile', () => {
'file is removed',
).not.toBeInTheDocument()
})

it('cannot add file, if the field is disabled', async () => {
const view = renderFileInput({
multiple: true,
value: [],
disabled: true,
})

const clickEvent = vi.fn()
HTMLInputElement.prototype.click = clickEvent

const fileButton = view.getByRole('button', { name: 'Attach files' })
expect(fileButton).toBeDisabled()
await view.events.click(fileButton)
expect(clickEvent).not.toHaveBeenCalled()
})
})

0 comments on commit ec7d3d2

Please sign in to comment.