-
Couldn't load subscription status.
- Fork 653
FileUploader: Implement internal file count limitation #31500
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
FileUploader: Implement internal file count limitation #31500
Conversation
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.
Pull Request Overview
This PR implements an internal file count limitation feature for the FileUploader component. The feature allows developers to set a maximum number of files that can be uploaded and provides a callback when this limit is reached.
Key Changes:
- Added
_maxFileCountoption to limit the number of files that can be selected - Implemented
onFileLimitReachedevent callback that fires when the file limit is exceeded - Added file count validation for both file input selection and drag-and-drop operations
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
packages/devextreme/js/__internal/ui/file_uploader/file_uploader.types.ts |
Added type definitions for FileLimitReachedEvent and the _maxFileCount and onFileLimitReached options |
packages/devextreme/js/__internal/ui/file_uploader/file_uploader.ts |
Implemented file limit validation logic, event handling, and integration with file input and drag-drop workflows |
packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/fileUploader.tests.js |
Added comprehensive test coverage for the file limit feature across multiple scenarios |
| if (this._isFileLimitReached(files as unknown as File[])) { | ||
| this._fileLimitReachedAction?.(); | ||
| } |
Copilot
AI
Oct 28, 2025
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.
The file limit check in _createFiles() incorrectly checks if the current files already exceed the limit, but doesn't prevent the files from being processed. This check should occur before files are added to the component, not after. The check here will always pass the current value to _isFileLimitReached, which will compare files.length + files.length, effectively doubling the count. This logic should be removed as the limit is already enforced in _inputChangeHandler and _dropHandler.
| if (this._isFileLimitReached(files as unknown as File[])) { | |
| this._fileLimitReachedAction?.(); | |
| } | |
| // File limit is enforced in _inputChangeHandler and _dropHandler |
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 logic is necessary when programmatically changing the value option or during the first render. But we can remove it after discussion with the team.
3cb4bd3 to
11e53e6
Compare
No description provided.