Skip to content

Commit

Permalink
fix: manage additional props passed on to getDropZoneProps
Browse files Browse the repository at this point in the history
  • Loading branch information
adrians5j committed Jan 1, 2019
1 parent 68ee686 commit 9856206
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/Files.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,31 +195,37 @@ class Files extends React.Component<Props> {
return (
<div>
{this.props.children({
browseFiles: params => {
this.browseFilesPassedParams = params;

// Opens the file browser.
this.input && this.input.click();
},
getLabelProps: (props: ?Object) => {
return {
...props,
htmlFor: id || this.id
};
},
getDropZoneProps: (props: ?Object) => {
browseFiles: ({ onSuccess, onError }: Object = {}) => {
this.browseFilesPassedParams = { onSuccess, onError };

// Opens the file browser.
this.input && this.input.click();
},
getDropZoneProps: ({
onSuccess,
onError,
onDragOver,
onDrop,
...rest
}: Object = {}) => {
this.browseFilesPassedParams = { onSuccess, onError };

return {
...props,
...rest,
onDragOver: e => {
e.preventDefault();
props &&
typeof props.onDragOver === "function" &&
props.onDragOver();
typeof onDragOver === "function" && onDragOver();
},
onDrop: async e => {
e.preventDefault();
await this.processSelectedFiles(e.dataTransfer.files);
props && typeof props.onDrop === "function" && props.onDrop();
typeof onDrop === "function" && onDrop();
}
};
}
Expand Down

0 comments on commit 9856206

Please sign in to comment.