Our use case for this is to offer a file uploader with a "replace" button that does remove add at once(we have restricted the file uploader to only a single file for this use case).
In addition we are looking to combine this and the download and remove buttons into a dropdown menu with the full names of each operation written out. This also has problems from the same source.
It is not currently possible to use the Upload itemRender
prop for this if you need to be able to manipulate the fileList after adding files to it.
There are workarounds such as:
item
fileList
manipulation logic.Both of these are comparable work to just building a file list from scratch.
The solution is to expose the bound file actions to the renderer. The following is the proposed type changes:
interface UploadFileActions {
download(): void
preview(): void
remove(): void
}
interface UploadProps<T = any> {
// ...
itemRender?: (
originNode: React.ReactElement,
file: UploadFile,
fileList?: Array<UploadFile<T>>,
actions: UploadFileActions
) => React.ReactNode;
// ...
}
Note: this API isn't the easiest to work with given the 4 arguments, however there aren't that many options that don't violate the contract of the existing API. Some alternatives that would also work:
file
objects in the code that calls itemRender
(this is pretty expensive and may cause issues for existing implementations that rely on the object identity being stable)Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too