From ed8c8cf093cc05fc1e635430981431df0c9341c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20San=20Mart=C3=ADn?= <57573579+nicolassanmar@users.noreply.github.com> Date: Wed, 23 Nov 2022 04:16:56 -0300 Subject: [PATCH] [@mantine/dropzone] Add `onDropAny` prop to capture both accepted and rejected files (#3010) --- src/mantine-dropzone/src/Dropzone.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mantine-dropzone/src/Dropzone.tsx b/src/mantine-dropzone/src/Dropzone.tsx index bd3422c3d42..a5a33b993fd 100644 --- a/src/mantine-dropzone/src/Dropzone.tsx +++ b/src/mantine-dropzone/src/Dropzone.tsx @@ -32,7 +32,10 @@ export interface DropzoneProps /** Disable files capturing */ disabled?: boolean; - /** Called when files are dropped into dropzone */ + /** Called when any files are dropped into dropzone */ + onDropAny?(files: FileWithPath[], fileRejections: FileRejection[]): void; + + /** Called when valid files are dropped into dropzone */ onDrop(files: FileWithPath[]): void; /** Called when selected files don't meet file restrictions */ @@ -122,6 +125,7 @@ export function _Dropzone(props: DropzoneProps) { maxSize, accept, children, + onDropAny, onDrop, onReject, openRef, @@ -149,6 +153,7 @@ export function _Dropzone(props: DropzoneProps) { ); const { getRootProps, getInputProps, isDragAccept, isDragReject, open } = useDropzone({ + onDrop: onDropAny, onDropAccepted: onDrop, onDropRejected: onReject, disabled: disabled || loading,