Skip to content

Commit

Permalink
added has files check
Browse files Browse the repository at this point in the history
  • Loading branch information
jloleysens committed Oct 20, 2022
1 parent 3fbc070 commit 794edc5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const UploadFile = React.forwardRef<EuiFilePicker, Props>(
ref={ref}
onChange={(fs) => {
uploadState.setFiles(Array.from(fs ?? []));
if (immediate) uploadState.upload(meta);
if (immediate && uploadState.hasFiles()) uploadState.upload(meta);
}}
multiple={false}
initialPromptText={initialFilePromptText}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ export class UploadState {
public dispose = (): void => {
for (const sub of this.subscriptions) sub.unsubscribe();
};

public hasFiles(): boolean {
return this.files$$.getValue().length > 0;
}
}

export const createUploadState = ({
Expand Down

0 comments on commit 794edc5

Please sign in to comment.