From 302ba655c3e4e0e423bffc5ce21c9859631d430c Mon Sep 17 00:00:00 2001 From: Kenny Daniel Date: Sat, 2 Nov 2024 13:54:44 -0700 Subject: [PATCH] demo: fix drag enter counts for non-files --- demo/Dropzone.tsx | 5 ++++- demo/bundle.min.js | 2 +- demo/bundle.min.js.map | 2 +- demo/demo.css | 13 +++++++++++-- package.json | 8 ++++---- 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/demo/Dropzone.tsx b/demo/Dropzone.tsx index a01dfa6..28aa2c9 100644 --- a/demo/Dropzone.tsx +++ b/demo/Dropzone.tsx @@ -67,7 +67,10 @@ export default function Dropzone({ children, onFileDrop, onUrlDrop, onError }: D function onDragOver(e: DragEvent) { e.preventDefault() } - function onDragLeave() { + function onDragLeave(e: DragEvent) { + const items = e.dataTransfer?.items + if (!items) return + if (!Array.from(items).some(item => item.kind === 'file')) return setEnters(enters => enters - 1) } function handleFileDrop(e: DragEvent) { diff --git a/demo/bundle.min.js b/demo/bundle.min.js index 54299f7..f43cfdd 100644 --- a/demo/bundle.min.js +++ b/demo/bundle.min.js @@ -7,5 +7,5 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */function _(){if(c)return v;c=1;var e=i(),t=w();function n(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n