Skip to content

Commit

Permalink
Fix primefaces#3750: FileUpload expose setFiles method
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Dec 7, 2022
1 parent d156afd commit 330ec60
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
12 changes: 10 additions & 2 deletions components/doc/fileupload/apidoc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import Link from 'next/link';
import { CodeHighlight } from '../common/codehighlight';
import { DevelopmentSection } from '../common/developmentsection';
import { DocSectionText } from '../common/docsectiontext';
import { DocSubSection } from '../common/docsubsection';

Expand Down Expand Up @@ -332,6 +330,16 @@ export function ApiDoc(props) {
<td>-</td>
<td>Clears the files list.</td>
</tr>
<tr>
<td>getFiles</td>
<td>-</td>
<td>Gets the current files list.</td>
</tr>
<tr>
<td>setFiles</td>
<td>File[]</td>
<td>Sets the current files list.</td>
</tr>
</tbody>
</table>
</div>
Expand Down
3 changes: 2 additions & 1 deletion components/lib/fileupload/FileUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ export const FileUpload = React.memo(
onFileSelect,
getInput: () => fileInputRef.current,
getContent: () => contentRef.current,
getFiles: () => filesState
getFiles: () => filesState,
setFiles: (files) => setFilesState(files || [])
}));

const createChooseButton = () => {
Expand Down
1 change: 1 addition & 0 deletions components/lib/fileupload/fileupload.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,5 @@ export declare class FileUpload extends React.Component<FileUploadProps, any> {
public getElement(): HTMLElement;
public getInput(): HTMLInputElement;
public getFiles(): File[];
public setFiles(files: File[]): void;
}

0 comments on commit 330ec60

Please sign in to comment.