Skip to content

Conversation

Nicoss54
Copy link
Collaborator

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Application (the showcase website) / infrastructure changes
  • Other... Please describe:

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?

  • Yes
  • No

Other information

Copy link

codecov bot commented Sep 17, 2025

Codecov Report

❌ Patch coverage is 83.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.38%. Comparing base (d0516e6) to head (15d3285).
⚠️ Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
components/upload/upload.component.ts 83.33% 2 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Nicoss54 Nicoss54 linked an issue Sep 17, 2025 that may be closed by this pull request
@Nicoss54 Nicoss54 force-pushed the feature/support-nz-max-count branch from d43cf19 to f2a6610 Compare September 17, 2025 14:08
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);
Copy link
Collaborator

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 🧐

Copy link
Collaborator Author

@Nicoss54 Nicoss54 Sep 18, 2025

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

Copy link
Collaborator

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

Image

Calling the hooks only if the file still exists in the list.
WDTY? @Nicoss54 @HyperLife1119

Copy link
Collaborator Author

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 :)

Copy link
Collaborator Author

@Nicoss54 Nicoss54 left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Difference Behavior between Ant design and ng zorro
3 participants