Skip to content

Commit

Permalink
adjust typing and example
Browse files Browse the repository at this point in the history
  • Loading branch information
LJKaski committed Jan 28, 2025
1 parent ddb3737 commit 183c9ed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/core/Form/FileInput/FileInput.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ const mockedItems = [

If you want to handle the file data without saving it to the component state, you can opt to provide only the necessary metadata to show the file in the component/list. You can then handle the file data as you want when saving the form.

Provide at least `fileName`, `fileType` and `fileSize` as the metadata of the controlled value object. File previews can also be handled either by providing a `fileURL` in the metadata or a `filePreviewOnClick` in the `ControlledFileItem` object.
Provide at least `fileName`, `fileType` and `fileSize` as the metadata of the controlled value object. File previews can also be handled either by providing a `fileURL` or a `filePreviewOnClick` in the `ControlledFileItem` object.

The interface for the metadata is as follows:

Expand Down Expand Up @@ -440,6 +440,7 @@ const customSaveFunction = (files) => {
value={controlledValue}
filePreview
multiFile
multiFileListHeadingText="Added files"
/>
</div>;
```
Expand Down
6 changes: 3 additions & 3 deletions src/core/Form/FileInput/FileItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface FileItemProps {
fileItemRefs: FileItemRefs;
addedFileAriaText: string;
removeFileText: ReactNode;
removeFile: (file: any) => void;
removeFile: (file: File) => void;
smallScreen: boolean;
fileItemDetails?: ControlledFileItem;
}
Expand Down Expand Up @@ -168,8 +168,8 @@ const BaseFileItem = (props: FileItemProps) => {
onClick={() => {
if (fileItemDetails?.buttonOnClick) {
fileItemDetails.buttonOnClick();
} else {
removeFile(file || fileItemDetails?.metadata);
} else if (file) {
removeFile(file);
}
}}
aria-label={`${
Expand Down

0 comments on commit 183c9ed

Please sign in to comment.