diff --git a/src/index.svelte b/src/index.svelte index b7322ac..054432e 100644 --- a/src/index.svelte +++ b/src/index.svelte @@ -2,12 +2,13 @@ import { getFilesFromDropEvent, getFilesFromInputEvent - } from "./_file-input-utils.mjs"; - import { createEventDispatcher } from "svelte"; + } from './_file-input-utils.mjs'; + import { createEventDispatcher } from 'svelte'; export let multiple = true; let dragging = false; + let files; const dispatch = createEventDispatcher(); function startDragging() { @@ -22,9 +23,13 @@ stopDragging(); const files = getFilesFunction(event); if (files.length) { - dispatch("input", { files: multiple ? files : files[0] }); + dispatch('input', { files: multiple ? files : files[0] }); } }; + + $: if (files && files.length) { + dispatch('input', { files: multiple ? files : files[0] }); + }