From 13fd0959daa283a3de092b050c07c34848fa01aa Mon Sep 17 00:00:00 2001 From: Kmaschta Date: Tue, 10 Dec 2019 18:11:49 +0100 Subject: [PATCH] Fix FileInput onDrop option --- packages/ra-ui-materialui/src/input/FileInput.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/ra-ui-materialui/src/input/FileInput.tsx b/packages/ra-ui-materialui/src/input/FileInput.tsx index 7a7d6fe6e62..7bbe454ea99 100644 --- a/packages/ra-ui-materialui/src/input/FileInput.tsx +++ b/packages/ra-ui-materialui/src/input/FileInput.tsx @@ -121,7 +121,7 @@ const FileInput: FunctionComponent< const { touched, error } = meta; const files = value ? (Array.isArray(value) ? value : [value]) : []; - const onDrop = newFiles => { + const onDrop = (newFiles, rejectedFiles, event) => { const updatedFiles = multiple ? [...files, ...newFiles] : [...newFiles]; if (multiple) { @@ -129,6 +129,10 @@ const FileInput: FunctionComponent< } else { onChange(updatedFiles[0]); } + + if (options.onDrop) { + options.onDrop(newFiles, rejectedFiles, event); + } }; const onRemove = file => () => { @@ -154,6 +158,7 @@ const FileInput: FunctionComponent< multiple, onDrop, }); + return (