Skip to content

Commit

Permalink
Make onDrop and onRemove optional as they are not needed when `re…
Browse files Browse the repository at this point in the history
…adOnly` is set
  • Loading branch information
jamesricky committed Jul 25, 2024
1 parent 490a895 commit c587461
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
6 changes: 3 additions & 3 deletions packages/admin/admin/src/form/file/FileSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ type ThemeProps = ThemedComponentBaseProps<{

export type FileSelectProps<AdditionalValidFileValues = Record<string, unknown>> = {
files: FileSelectItem<AdditionalValidFileValues>[];
onDrop: DropzoneOptions["onDrop"];
onRemove: (file: FileSelectItem<AdditionalValidFileValues>) => void;
onDrop?: DropzoneOptions["onDrop"];
onRemove?: (file: FileSelectItem<AdditionalValidFileValues>) => void;
onDownload?: (file: FileSelectItem<AdditionalValidFileValues>) => void;
disabled?: boolean;
readOnly?: boolean;
Expand Down Expand Up @@ -128,7 +128,7 @@ export const FileSelect = <AdditionalValidFileValues = Record<string, unknown>,>
onDownload(file);
}
}
onClickDelete={readOnly ? undefined : () => onRemove(file)}
onClickDelete={readOnly || !onRemove ? undefined : () => onRemove(file)}
{...slotProps?.fileListItem}
/>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ storiesOf("stories/components/FileSelect", module)

return (
<FileSelect
onDrop={(acceptedFiles, fileRejections) => {
// Handle what happens with the dropped files
}}
onRemove={(file) => {
// Handle remove
}}
onDownload={(file) => {
// Handle download
}}
Expand Down

0 comments on commit c587461

Please sign in to comment.