-
Notifications
You must be signed in to change notification settings - Fork 4.1k
feat(module:upload): add nzMaxCount
feature
#9424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9424 +/- ##
==========================================
- Coverage 91.39% 91.38% -0.01%
==========================================
Files 561 561
Lines 19734 19745 +11
Branches 3031 3148 +117
==========================================
+ Hits 18035 18044 +9
- Misses 1371 1373 +2
Partials 328 328 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
d43cf19
to
f2a6610
Compare
private onProgress = (e: { percent: number }, file: NzUploadFile): void => { | ||
const fileList = this.nzFileList; | ||
const targetItem = this.getFileItem(file, fileList); | ||
const targetItem = this.getFileItem(file, fileList) || this.fileToObject(file); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to know the reason for this change, because normally, the file in the upload state must be in the fileList 🧐
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NzNaxCount prevent to have a file in the list if the list.length is equal or superior to nzMaxCount.
So imagine nzMaxCount is 2, the third file is not adding in the list but as ant design work the third file is still upload so we need to send it in nzChange
We add the file in the onStart hook, but in this hook we add the Logic of nzMaxCount so potentially in the progress and error hook the file is not in the file list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about following antd's logic? -> https://github.com/ant-design/ant-design/blob/master/components/upload/Upload.tsx

Calling the hooks only if the file still exists in the list.
WDTY? @Nicoss54 @HyperLife1119
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This make sense on my side and the change are already implemented @Laffery @HyperLife1119 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@HyperLife1119 all change requested are implemented
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Upload Component can now support nzMaxCount to limit the number of file displayed in the list
Does this PR introduce a breaking change?
Other information