Skip to content

Commit

Permalink
Fix #5664: FileUpload progress template (#5665)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored and nitrogenous committed Jan 4, 2024
1 parent 4c9f9bd commit 1277ce4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
10 changes: 7 additions & 3 deletions components/lib/fileupload/FileUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,7 @@ export const FileUpload = React.memo(
};

const onKeyDown = (event) => {
if (event.which === 13) {
// enter
if (event.code === 'Enter') {
choose();
}
};
Expand Down Expand Up @@ -530,7 +529,12 @@ export const FileUpload = React.memo(

const createProgressBarContent = () => {
if (props.progressBarTemplate) {
return ObjectUtils.getJSXElement(props.progressBarTemplate, props);
const defaultProgressBarTemplateOptions = {
progress: progressState,
props
};

return ObjectUtils.getJSXElement(props.progressBarTemplate, defaultProgressBarTemplateOptions);
}

return <ProgressBar value={progressState} showValue={false} pt={ptm('progressbar')} __parentMetadata={{ parent: metaData }} />;
Expand Down
18 changes: 17 additions & 1 deletion components/lib/fileupload/fileupload.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,22 @@ interface FileUploadHeaderTemplateOptions {
props: FileUploadProps;
}

/**
* Custom file upload progressbar template options
*/
interface FileUploadProgressBarTemplateOptions {
/**
* Current progress state as a number.
* @defaultValue 0
*/
progress: number;
/**
* The props passed to the component.
* @type {FileUploadProps}
*/
props: FileUploadProps;
}

/**
* Custom item template options
*/
Expand Down Expand Up @@ -532,7 +548,7 @@ interface FileUploadProps {
/**
* Custom template of progressBar content in the container.
*/
progressBarTemplate?: React.ReactNode | ((props: FileUploadProps) => React.ReactNode);
progressBarTemplate?: React.ReactNode | ((options: FileUploadProgressBarTemplateOptions) => React.ReactNode);
/**
* Callback to invoke before file upload begins to customize the request such as post parameters before the files.
* @param {FileUploadBeforeUploadEvent} event - Custom beforeUpload.
Expand Down

0 comments on commit 1277ce4

Please sign in to comment.