thecodejack / svelte-file-dropzone

Svelte component for fileupload
https://svelte-file-dropzone.netlify.app/
252 stars 45 forks source link

the properties are not reactive - disable. #145

Closed AdrianNigro closed 9 months ago

AdrianNigro commented 1 year ago

the properties are not reactive,

example: if the value of disabled changes the component doesn't change his behavior

example code:

<script>
    import Dropzone from 'svelte-file-dropzone/Dropzone.svelte'
    import { onMount } from 'svelte'

    export let disabled = false

    onMount(async () => {
        if (condition) disabled = true
    })
</script>

<Dropzone
    ...
    {disabled}
></Dropzone>
matt-asmblr commented 1 year ago

Also experiencing this issue, looks to be the way the event handler functions are 'composed'

function composeHandler(fn) {
    return disabled ? null : fn;
  }

<div
  ...
 on:click={composeHandler(onClickCb)}
  ...
/>

In this example, if disabled is false initially, the handler function will always be null

thecodejack commented 12 months ago

Can you raise PR with the fix?