Repository navigation
feat(data-grid): show file validation toasts #1029
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1364,12 +1364,12 @@ export function FileCell<TData>({ | |||||||||
| return file.type === type; | ||||||||||
| }); | ||||||||||
| if (!isAccepted) { | ||||||||||
| return `File type not accepted. Accepted: ${accept}`; | ||||||||||
| return "File type not accepted"; | ||||||||||
| } | ||||||||||
| } | ||||||||||
| return null; | ||||||||||
| }, | ||||||||||
| [maxFileSize, acceptedTypes, accept], | ||||||||||
| [maxFileSize, acceptedTypes], | ||||||||||
| ); | ||||||||||
|
|
||||||||||
| const addFiles = React.useCallback( | ||||||||||
|
|
@@ -1378,19 +1378,22 @@ export function FileCell<TData>({ | |||||||||
|
|
||||||||||
| // Check max files limit | ||||||||||
| if (maxFiles && files.length + newFiles.length > maxFiles) { | ||||||||||
| setError(`Maximum ${maxFiles} files allowed`); | ||||||||||
| const errorMessage = `Maximum ${maxFiles} files allowed`; | ||||||||||
| setError(errorMessage); | ||||||||||
| toast(errorMessage); | ||||||||||
|
||||||||||
| toast(errorMessage); | |
| toast(errorMessage, { | |
| description: "Please remove some files before adding more", | |
| }); |
Copilot
AI
Nov 20, 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.
Potential memory leak: The setTimeout is not cleaned up if the component unmounts before the timeout fires. Store the timeout ID and clean it up in a useEffect cleanup function to prevent setting state on an unmounted component.
Copilot
AI
Nov 20, 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.
Accessibility concern: The error state is used for aria-invalid (line 1736), but it's automatically cleared after 2 seconds via setTimeout. This means screen readers and assistive technologies will lose the invalid state even though the user hasn't corrected the issue. Consider either not auto-clearing the error state, or only clearing it when the user takes a corrective action (e.g., removing files, closing the dialog).
| setTimeout(() => { | |
| setError(null); | |
| }, 2000); |
Copilot
AI
Nov 20, 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.
Potential memory leak: The setTimeout is not cleaned up if the component unmounts before the timeout fires. Store the timeout ID and clean it up in a useEffect cleanup function to prevent setting state on an unmounted component.
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.
Usability regression: Removing the accepted file types from the error message (
Accepted: ${accept}) means users no longer see which file types are accepted when their upload is rejected. Consider adding this information back to the toast notification, perhaps in the description field, or display accepted file types in the dropzone UI (lines 1758-1764) alongside the max size and max files information.