diff --git a/src/DirectUploadProvider.js b/src/DirectUploadProvider.js index e734dfc..4202618 100644 --- a/src/DirectUploadProvider.js +++ b/src/DirectUploadProvider.js @@ -100,6 +100,7 @@ class DirectUploadProvider extends React.Component { [string]: ActiveStorageFileUpload, }) => this.setState(({ fileUploads }) => ({ + uploading: false, fileUploads: { ...fileUploads, ...fileUpload }, })) diff --git a/src/DirectUploadProvider.test.js b/src/DirectUploadProvider.test.js index d1230af..c784c05 100644 --- a/src/DirectUploadProvider.test.js +++ b/src/DirectUploadProvider.test.js @@ -109,4 +109,15 @@ describe('DirectUploadProvider', () => { await tree.props.handleUpload([file]) expect(onSuccess).toHaveBeenCalledWith(['signedId']) }) + + it('is ready for another upload when an error happens', async () => { + fetch.mockRejectedValue(new Error('Fetch error')) + + await tree.props.handleUpload([file]) + expect(component.getInstance().state.uploading).toBe(false) + + // Try to upload again + await tree.props.handleUpload([file]) + expect(component.getInstance().state.uploading).toBe(false) + }) })