Skip to content

Commit 046e493

Browse files
committed
fix: onStart should ignore beforeUpload false
1 parent af83ac2 commit 046e493

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/AjaxUploader.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,14 @@ class AjaxUploader extends Component<UploadProps> {
108108
// Batch upload files
109109
Promise.all(postFiles).then(fileList => {
110110
const { onBatchStart } = this.props;
111-
const enabledFiles = fileList.filter(file => file);
112111

113112
onBatchStart?.(fileList.map(({ origin, parsedFile }) => ({ file: origin, parsedFile })));
114113

115-
enabledFiles.forEach(file => {
116-
this.post(file);
117-
});
114+
fileList
115+
.filter(file => file.parsedFile !== null)
116+
.forEach(file => {
117+
this.post(file);
118+
});
118119
});
119120
};
120121

tests/uploader.spec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,10 @@ describe('uploader', () => {
516516
return true;
517517
});
518518

519-
const onBatchStart = await testWrapper({ beforeUpload });
519+
const onStart = jest.fn();
520+
const onBatchStart = await testWrapper({ beforeUpload, onStart });
520521

522+
expect(onStart).toHaveBeenCalledTimes(1);
521523
expect(beforeUpload).toHaveBeenCalledTimes(2);
522524
expect(onBatchStart).toHaveBeenCalledWith(
523525
files.map(file =>

0 commit comments

Comments
 (0)